mirror of
https://github.com/tc39/test262.git
synced 2025-05-16 12:50:37 +02:00
* Move decimalToHexString into harness instead of duplicating it in multiple files * Optimize decimalToHexString and support numbers greater than 65535 * Replace alternative decimalToHexString function with include for decimalToHexString.js * Add decimalToHex2String to return the string representation of a two-digit hex-number * Replace decimalToHex2String with decimalToPercentHexString to return the percent hex-encoded string of a two-digit hex-number * Replace two String.fromCharCode calls with a single call * Further reduce string concatentations in decodeURI[Component] tests * Remove unnecessary Test262Error error handling in catch-clauses * Remove try/catch wrappings in decodeURI/encodeURI tests
22 lines
466 B
JavaScript
22 lines
466 B
JavaScript
// Copyright (C) 2017 André Bargull. All rights reserved.
|
|
// This code is governed by the BSD license found in the LICENSE file.
|
|
|
|
function decimalToHexString(n) {
|
|
var hex = "0123456789ABCDEF";
|
|
n >>>= 0;
|
|
var s = "";
|
|
while (n) {
|
|
s = hex[n & 0xf] + s;
|
|
n >>>= 4;
|
|
}
|
|
while (s.length < 4) {
|
|
s = "0" + s;
|
|
}
|
|
return s;
|
|
}
|
|
|
|
function decimalToPercentHexString(n) {
|
|
var hex = "0123456789ABCDEF";
|
|
return "%" + hex[(n >> 4) & 0xf] + hex[n & 0xf];
|
|
}
|