| 231 | } |
| 232 | |
| 233 | [[nodiscard]] |
| 234 | static bool is_utf8_label(const char* encoding) { |
| 235 | // We could be smarter about utf8 synonyms here. |
| 236 | // For now, we handle any casing and trailing/leading |
| 237 | // whitespace. |
| 238 | // |
| 239 | // is_utf8_label is only an optimization, so if a label |
| 240 | // doesn't match we just use the slower path. |
| 241 | if (g_ascii_strcasecmp(encoding, "utf-8") == 0 || |
| 242 | g_ascii_strcasecmp(encoding, "utf8") == 0) |
| 243 | return true; |
| 244 | |
| 245 | Gjs::AutoChar stripped{g_strdup(encoding)}; |
| 246 | g_strstrip(stripped); // modifies in place |
| 247 | return g_ascii_strcasecmp(stripped, "utf-8") == 0 || |
| 248 | g_ascii_strcasecmp(stripped, "utf8") == 0; |
| 249 | } |
| 250 | |
| 251 | // Finds the length of a given data array, stopping at the first 0 byte. |
| 252 | template <class T> |
no outgoing calls
no test coverage detected