Jsctypes/api: Difference between revisions

Line 686: Line 686:
* If ''cdata'' is an array, let ''p'' = a pointer to the first element. Otherwise ''cdata'' is a pointer; let ''p'' = the value of ''cdata''.
* If ''cdata'' is an array, let ''p'' = a pointer to the first element. Otherwise ''cdata'' is a pointer; let ''p'' = the value of ''cdata''.
* 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; ''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.  ''(The result may contain null characters.)''
* 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.  ''(If ''cdata'' is a pointer and there is no trailing null character, this can crash.)''
* 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.)''
148

edits