* gjs_unichar_from_string: * @string: A string * @result: (out): A unicode character * * If successful, @result is assigned the Unicode codepoint * corresponding to the first full character in @string. This * function handles characters outside the BMP. * * If @string is empty, @result will be 0. An exception will * be thrown if @string can not be represented as UTF-8. */
| 435 | * be thrown if @string can not be represented as UTF-8. |
| 436 | */ |
| 437 | bool gjs_unichar_from_string(JSContext* cx, JS::Value value, gunichar* result) { |
| 438 | JS::UniqueChars utf8_str{gjs_string_to_utf8(cx, value)}; |
| 439 | if (utf8_str) { |
| 440 | *result = g_utf8_get_char(utf8_str.get()); |
| 441 | return true; |
| 442 | } |
| 443 | return false; |
| 444 | } |
| 445 | |
| 446 | jsid gjs_intern_string_to_id(JSContext* cx, const char* string) { |
| 447 | JS::RootedString str(cx, JS_AtomizeAndPinString(cx, string)); |
no test coverage detected