Jsctypes/api: Difference between revisions

Line 687: Line 687:
* If ''encoding'' is <code>undefined</code> or omitted, the selected encoding is UTF-8. Otherwise, if ''encoding'' is a string naming a known character encoding, that encoding is selected. Otherwise throw a <code>TypeError</code>.
* If ''encoding'' is <code>undefined</code> or omitted, the selected encoding is UTF-8. Otherwise, if ''encoding'' is a string naming a known character encoding, that encoding is selected. Otherwise throw a <code>TypeError</code>.
* If ''length'' is a size value, ''cdata'' is an array, and <code>''length'' &gt; <code>''cdata''.length</code>, then throw a <code>TypeError</code>.
* If ''length'' is a size value, ''cdata'' is an array, and <code>''length'' &gt; <code>''cdata''.length</code>, then throw a <code>TypeError</code>.
* Otherwise, if ''length'' is a size value, take exactly ''length'' bytes starting at ''p'' and convert them to Unicode characters according to the selected encoding. ''(Open issue: Error handling.)'' Return a JavaScript string containing the Unicode characters, represented in UTF-16.
* Otherwise, if ''length'' is a size value, take exactly ''length'' bytes starting at ''p'' and convert them to Unicode characters according to the selected encoding. ''(Open issue: Error handling.)'' Return a JavaScript string containing the Unicode characters, represented in UTF-16. ''(The result may contain null characters.)''
* Otherwise, if ''length'' is <code>undefined</code> or omitted, convert bytes starting at ''p'' to Unicode characters according to the selected encoding. Stop when the end of the array is reached (if ''cdata'' is an array) or when a null character (U+0000) is found. ''(Open issue: Error handling.)'' Return a JavaScript string containing the Unicode characters, represented in UTF-16.
* Otherwise, if ''length'' is <code>undefined</code> or omitted, convert bytes starting at ''p'' to Unicode characters according to the selected encoding. Stop when the end of the array is reached (if ''cdata'' is an array) or when a null character (U+0000) is found. ''(Open issue: Error handling.)'' Return a JavaScript string containing the Unicode characters, represented in UTF-16. ''(If ''cdata'' is a pointer and there is no trailing null character, this can crash.)''
* Otherwise throw a <code>TypeError</code>.
* Otherwise throw a <code>TypeError</code>.


Line 698: Line 698:


''(Open issue: 16-bit versions too, for UTF-16?)''
''(Open issue: 16-bit versions too, for UTF-16?)''


==isNull==
==isNull==
638

edits