| 2027 | } |
| 2028 | |
| 2029 | CharString String::ascii(bool p_allow_extended) const |
| 2030 | { |
| 2031 | if (!length()) |
| 2032 | { |
| 2033 | return CharString(); |
| 2034 | } |
| 2035 | |
| 2036 | CharString cs; |
| 2037 | cs.resize(size()); |
| 2038 | |
| 2039 | for (int i = 0; i < size(); i++) |
| 2040 | { |
| 2041 | char32_t c = operator[](i); |
| 2042 | if ((c <= 0x7f) || (c <= 0xff && p_allow_extended)) |
| 2043 | { |
| 2044 | cs[i] = c; |
| 2045 | } |
| 2046 | else |
| 2047 | { |
| 2048 | print_unicode_error("Invalid unicode codepoint " + num_int64(c) + ", cannot represent as ASCII/Latin-1"); |
| 2049 | cs[i] = 0x20; |
| 2050 | } |
| 2051 | } |
| 2052 | |
| 2053 | return cs; |
| 2054 | } |
| 2055 | |
| 2056 | String String::utf8(const char* p_utf8, int p_len) |
| 2057 | { |
no test coverage detected