| 1025 | static unsigned char safeChars[256]; |
| 1026 | |
| 1027 | String String::__URLEncode() const |
| 1028 | { |
| 1029 | Array<unsigned char> bytes(0,length); |
| 1030 | // utf8-encode |
| 1031 | __hxcpp_bytes_of_string(bytes,*this); |
| 1032 | |
| 1033 | int extra = 0; |
| 1034 | int utf8_chars = bytes->__length(); |
| 1035 | for(int i=0;i<utf8_chars;i++) |
| 1036 | if (!safeChars[bytes[i]]) |
| 1037 | extra++; |
| 1038 | if (extra==0) |
| 1039 | return *this; |
| 1040 | |
| 1041 | int l = utf8_chars + extra*2; |
| 1042 | char *result = hx::NewString(l); |
| 1043 | char *ptr = result; |
| 1044 | |
| 1045 | for(int i=0;i<utf8_chars;i++) |
| 1046 | { |
| 1047 | if (!safeChars[bytes[i]]) |
| 1048 | { |
| 1049 | static char hex[] = "0123456789ABCDEF"; |
| 1050 | unsigned char b = bytes[i]; |
| 1051 | *ptr++ = '%'; |
| 1052 | *ptr++ = hex[ b>>4 ]; |
| 1053 | *ptr++ = hex[ b & 0x0f ]; |
| 1054 | } |
| 1055 | else |
| 1056 | *ptr++ = bytes[i]; |
| 1057 | } |
| 1058 | return String(result,l); |
| 1059 | } |
| 1060 | |
| 1061 | String String::toUpperCase() const |
| 1062 | { |
nothing calls this directly
no test coverage detected