| 184 | } |
| 185 | |
| 186 | bool gjs_string_from_utf8(JSContext* cx, const char* utf8_string, |
| 187 | JS::MutableHandleValue value_p) { |
| 188 | JS::ConstUTF8CharsZ chars(utf8_string, strlen(utf8_string)); |
| 189 | JS::RootedString str{cx, JS_NewStringCopyUTF8Z(cx, chars)}; |
| 190 | if (!str) |
| 191 | return false; |
| 192 | |
| 193 | value_p.setString(str); |
| 194 | return true; |
| 195 | } |
| 196 | |
| 197 | bool gjs_string_from_utf8_n(JSContext* cx, const char* utf8_chars, size_t len, |
| 198 | JS::MutableHandleValue out) { |
no outgoing calls