[Bug 17620] New: Add steps to convert a sequence of Unicode characters to a DOMString

https://www.w3.org/Bugs/Public/show_bug.cgi?id=17620

           Summary: Add steps to convert a sequence of Unicode characters
                    to a DOMString
           Product: WebAppsWG
           Version: unspecified
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: WebIDL
        AssignedTo: cam@mcc.id.au
        ReportedBy: jsbell@chromium.org
         QAContact: public-webapps-bugzilla@w3.org
                CC: mike@w3.org, public-script-coord@w3.org


The Web API proposed in http://wiki.whatwg.org/wiki/StringEncoding requires
interpretation of DOMString code units as an encoding of Unicode characters for
the purpose of encoding and decoding DOMStrings to other binary encodings.

WebIDL defines "steps to convert a DOMString to a sequence of Unicode
characters" at http://dev.w3.org/2006/webapi/WebIDL/#dfn-obtain-unicode

The proposed API require the reverse as well, and defines "steps to convert a
sequence of Unicode characters to a DOMString" at
http://wiki.whatwg.org/wiki/StringEncoding#Steps_to_convert_a_sequence_of_Unicode_characters_to_a_DOMString

Would it be possible to add the latter to the WebIDL specification so that both
directions are defined in one place?

The proposed text could be (sans-formatting, using _ for subscript and ^ for
superscript):

The following algorithm defines a way to convert a sequence of Unicode
characters to a DOMString:
1. Let U_0...n-1 be the sequence of Unicode characters
2. Initialize i to 0
3. Initialize S to be an empty sequence of code units
4. While i < n
    1. Let c be the code point of the Unicode character in U at index i
    2. If c ≥ 2^16, then:
        1. Append to S a code unit equal to (c - 2^16) / 2^10 + 0xD800, where
"/" represents integer division.
        2. Append to S a code unit equal to (c - 2^16) % 2^10 + 0xDC00, where
"%" represents the remainder of an integer division.
    3. Otherwise, append to S a code unit equal to c.
    4. Set i to i+1
5. Return the IDL DOMString value that represents sequence of code units S.

-- 
Configure bugmail: https://www.w3.org/Bugs/Public/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.

Received on Wednesday, 27 June 2012 20:31:31 UTC