@@ -5,10 +5,10 @@ void FB_escHTML(String& s) {
5
5
out.reserve (s.length ());
6
6
for (uint16_t i = 0 ; i < s.length (); i++) {
7
7
switch (s[i]) {
8
- case ' <' : out += F (" <" ); break ;
9
- case ' >' : out += F (" >" ); break ;
10
- case ' &' : out += F (" &" ); break ;
11
- default : out += s[i]; break ;
8
+ case ' <' : out += F (" <" ); break ;
9
+ case ' >' : out += F (" >" ); break ;
10
+ case ' &' : out += F (" &" ); break ;
11
+ default : out += s[i]; break ;
12
12
}
13
13
}
14
14
s = out;
@@ -26,11 +26,21 @@ void FB_escMarkdown(String& s) {
26
26
s = out;
27
27
}
28
28
29
- int64_t FB_str64 (const String & s) {
29
+ int64_t FB_str64 (const String& s) {
30
30
return atoll (s.c_str ());
31
31
}
32
32
String FB_64str (int64_t id) {
33
- return String (id);
33
+ bool neg = 0 ;
34
+ if (id < 0 ) id = -id, neg = 1 ;
35
+ char str[21 ];
36
+ char * p = str + 21 ;
37
+ *--p = 0 ;
38
+ do {
39
+ *--p = id % 10 + ' 0' ;
40
+ id /= 10 ;
41
+ } while (id);
42
+ if (neg) *--p = ' -' ;
43
+ return p;
34
44
}
35
45
36
46
// упрощённый urlencode (до 38 ASCII + space)
@@ -45,14 +55,13 @@ void FB_urlencode(const String& s, String& dest) {
45
55
dest += ' %' ;
46
56
dest += (char )((c >> 4 ) + (((c >> 4 ) > 9 ) ? 87 : 48 ));
47
57
dest += (char )((c & 0xF ) + (((c & 0xF ) > 9 ) ? 87 : 48 ));
48
- }
49
- else dest += c;
58
+ } else dest += c;
50
59
}
51
60
}
52
61
53
62
// разработано Глебом Жуковым, допилено AlexGyver
54
63
// https://vk.com/wall-97877471_783011
55
- void FB_unicode (String & uStr) {
64
+ void FB_unicode (String& uStr) {
56
65
if (!uStr.length ()) return ;
57
66
String out;
58
67
out.reserve (uStr.length () / 3 );
@@ -62,36 +71,36 @@ void FB_unicode(String &uStr) {
62
71
if (uStr[i] != ' \\ ' ) out += uStr[i];
63
72
else {
64
73
switch (uStr[++i]) {
65
- case ' 0' : break ;
66
- case ' n' : out += ' \n ' ; break ;
67
- case ' r' : out += ' \r ' ; break ;
68
- case ' t' : out += ' \t ' ; break ;
69
- case ' u' :
70
- uBytes = strtol (uStr.substring (i + 1 , i + 5 ).c_str (), NULL , HEX);
71
- i += 4 ;
72
- if ((uBytes >= 0xD800 ) && (uBytes <= 0xDBFF )) buf = uBytes;
73
- else if ((uBytes >= 0xDC00 ) && (uBytes <= 0xDFFF )) {
74
- uBytes = (0x10000 + ((buf - 0xD800 ) * 0x0400 ) + (uBytes - 0xDC00 ));
75
- out += (char )(0b11110000 | ((uBytes >> 18 ) & 0b111 ));
76
- out += x0;
77
- out += (char )(0b10000000 | ((uBytes >> 12 ) & 0b111111 ));
78
- out += x0;
79
- out += (char )(0b10000000 | ((uBytes >> 6 ) & 0b111111 ));
80
- out += x0;
81
- out += (char )(0b10000000 | (uBytes & 0b111111 ));
82
- } else if (uBytes < 0x800 ) {
83
- out += (char )(0b11000000 | ((uBytes >> 6 ) & 0b11111 ));
84
- out += x0;
85
- out += (char )(0b10000000 | (uBytes & 0b111111 ));
86
- } else if (uBytes >= 0x800 ) {
87
- out += (char )(0b11100000 | ((uBytes >> 12 ) & 0b1111 ));
88
- out += x0;
89
- out += (char )(0b10000000 | ((uBytes >> 6 ) & 0b111111 ));
90
- out += x0;
91
- out += (char )(0b10000000 | (uBytes & 0b111111 ));
92
- }
93
- break ;
94
- default : out += uStr[i]; break ;
74
+ case ' 0' : break ;
75
+ case ' n' : out += ' \n ' ; break ;
76
+ case ' r' : out += ' \r ' ; break ;
77
+ case ' t' : out += ' \t ' ; break ;
78
+ case ' u' :
79
+ uBytes = strtol (uStr.substring (i + 1 , i + 5 ).c_str (), NULL , HEX);
80
+ i += 4 ;
81
+ if ((uBytes >= 0xD800 ) && (uBytes <= 0xDBFF )) buf = uBytes;
82
+ else if ((uBytes >= 0xDC00 ) && (uBytes <= 0xDFFF )) {
83
+ uBytes = (0x10000 + ((buf - 0xD800 ) * 0x0400 ) + (uBytes - 0xDC00 ));
84
+ out += (char )(0b11110000 | ((uBytes >> 18 ) & 0b111 ));
85
+ out += x0;
86
+ out += (char )(0b10000000 | ((uBytes >> 12 ) & 0b111111 ));
87
+ out += x0;
88
+ out += (char )(0b10000000 | ((uBytes >> 6 ) & 0b111111 ));
89
+ out += x0;
90
+ out += (char )(0b10000000 | (uBytes & 0b111111 ));
91
+ } else if (uBytes < 0x800 ) {
92
+ out += (char )(0b11000000 | ((uBytes >> 6 ) & 0b11111 ));
93
+ out += x0;
94
+ out += (char )(0b10000000 | (uBytes & 0b111111 ));
95
+ } else if (uBytes >= 0x800 ) {
96
+ out += (char )(0b11100000 | ((uBytes >> 12 ) & 0b1111 ));
97
+ out += x0;
98
+ out += (char )(0b10000000 | ((uBytes >> 6 ) & 0b111111 ));
99
+ out += x0;
100
+ out += (char )(0b10000000 | (uBytes & 0b111111 ));
101
+ }
102
+ break ;
103
+ default : out += uStr[i]; break ;
95
104
}
96
105
}
97
106
}
0 commit comments