MCPcopy Create free account
hub / github.com/GNOME/gjs / gjs_lossy_string_from_utf8_n

Function gjs_lossy_string_from_utf8_n

gjs/jsapi-util-string.cpp:172–184  ·  view source on GitHub ↗

* gjs_lossy_string_from_utf8_n: * @cx: the current #JSContext * @utf8_string: an array of UTF-8 characters to decode * @len: length of @utf8_string * * Provides the same conversion behavior as gjs_lossy_string_from_utf8 * with a fixed length. See gjs_lossy_string_from_utf8(). * * Returns: The decoded string. */

Source from the content-addressed store, hash-verified

170 * Returns: The decoded string.
171 */
172JSString* gjs_lossy_string_from_utf8_n(JSContext* cx, const char* utf8_string,
173 size_t len) {
174 JS::UTF8Chars chars(utf8_string, len);
175 size_t outlen;
176 JS::UniqueTwoByteChars twobyte_chars(
177 JS::LossyUTF8CharsToNewTwoByteCharsZ(cx, chars, &outlen,
178 js::MallocArena)
179 .get());
180 if (!twobyte_chars)
181 return nullptr;
182
183 return JS_NewUCStringCopyN(cx, twobyte_chars.get(), outlen);
184}
185
186bool gjs_string_from_utf8(JSContext* cx, const char* utf8_string,
187 JS::MutableHandleValue value_p) {

Callers 1

Calls 1

getMethod · 0.45

Tested by

no test coverage detected