10 examples of 'javascript char to int' in JavaScript

Every line of 'javascript char to int' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your JavaScript code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
this disclaimer
200function char_(str, i) {
201 return str.charCodeAt(i);
202}
Important

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

1function getCharCode(char) {
2 return char.charCodeAt(0);
3}
9function fromHEXDigit(char) {
10 if (0x61 <= char && char <= 0x66)
11 return char - 0x61 + 10;
12 if (0x41 <= char && char <= 0x46)
13 return char - 0x41 + 10;
14 if (0x30 <= char && char <= 0x39)
15 return char - 0x30;
16 return 0;
17}
36function codePointToInt(codePoint) {
37 if (codePoint >= 48 && codePoint <= 57) { /*['0'..'9'] -> [0..9]*/
38 return codePoint-48;
39 }
40
41 if (codePoint >= 65 && codePoint <= 70) { /*['A'..'F'] -> [10..15]*/
42 return codePoint-55;
43 }
44
45 if (codePoint >= 97 && codePoint <= 102) { /*['a'..'f'] -> [10..15]*/
46 return codePoint-87;
47 }
48
49 throw "invalid bloom";
50}
83function _char(c) {
84 if (!_CHARS[c]) {
85 _CHARS[c] = '\\u'+('0000'+(+(c.charCodeAt(0))).toString(16)).slice(-4);
86 }
87 return _CHARS[c];
88}
1function dec2char ( n ) {
2 // converts a decimal number to a Unicode character
3 // n: the dec codepoint value to be converted
4 if (n <= 0xFFFF) { out = String.fromCharCode(n) }
5 else if (n <= 0x10FFFF) {
6 n -= 0x10000
7 out = String.fromCharCode(0xD800 | (n >> 10)) + String.fromCharCode(0xDC00 | (n & 0x3FF))
8 }
9 else out = 'dec2char error: Code point out of range: '+n
10 return out
11 }
803function JSChar(c) {
804 JSString.call(this, c);
805}
18function character (n) {
19 return " " + n + " символ" + (n%10 < 5 && n%10 > 0 && (n%100 < 5 || n%100 > 20) ? n%10 > 1 ? "a" : "" : "ов");
20}
70function int(s) {
71 return parseInt(s);
72}
73function getCode(char){
74
75 switch(char){
76
77 case 'b':
78 case 'f':
79 case 'p':
80 case 'v':
81 return 1;
82 case 'c':
83 case 'g':
84 case 'j':
85 case 'k':
86 case 'q':
87 case 's':
88 case 'x':
89 case 'z':
90 return 2;
91 case 'd':
92 case 't':
93 return 3;
94 case 'l':
95 return 4;
96 case 'm':
97 case 'n':
98 return 5;
99 case 'r':
100 return 6;
101 }
102
103 return "";
104}

Related snippets