File tree 2 files changed +4
-10
lines changed
2 files changed +4
-10
lines changed Original file line number Diff line number Diff line change @@ -14,7 +14,5 @@ function chr (codePt) {
14
14
codePt -= 0x10000 ;
15
15
return String . fromCharCode ( 0xD800 + ( codePt >> 10 ) , 0xDC00 + ( codePt & 0x3FF ) ) ;
16
16
}
17
- else {
18
- return String . fromCharCode ( codePt ) ;
19
- }
17
+ return String . fromCharCode ( codePt ) ;
20
18
}
Original file line number Diff line number Diff line change @@ -3,23 +3,19 @@ function ord (string) {
3
3
// + original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
4
4
// + bugfixed by: Onno Marsman
5
5
// + improved by: Brett Zamir (http://brett-zamir.me)
6
+ // + input by: incidence
6
7
// * example 1: ord('K');
7
8
// * returns 1: 75
8
9
// * example 2: ord('\uD800\uDC00'); // surrogate pair to create a single Unicode character
9
10
// * returns 2: 65536
10
11
11
- var str = string + '' ;
12
-
13
- var code = str . charCodeAt ( 0 ) ;
12
+ var str = string + '' ,
13
+ code = str . charCodeAt ( 0 ) ;
14
14
if ( 0xD800 <= code && code <= 0xDBFF ) { // High surrogate (could change last hex to 0xDB7F to treat high private surrogates as single characters)
15
15
var hi = code ;
16
16
if ( str . length === 1 ) {
17
17
return code ; // This is just a high surrogate with no following low surrogate, so we return its value;
18
18
// we could also throw an error as it is not a complete character, but someone may want to know
19
- }
20
- var low = str . charCodeAt ( 1 ) ;
21
- if ( ! low ) {
22
-
23
19
}
24
20
return ( ( hi - 0xD800 ) * 0x400 ) + ( low - 0xDC00 ) + 0x10000 ;
25
21
}
You can’t perform that action at this time.
0 commit comments