Open
Bug 552551
Opened 15 years ago
Updated 2 years ago
Fill out ctypes charset conversion API
Categories
(Core :: js-ctypes, defect, P5)
Core
js-ctypes
Tracking
()
NEW
People
(Reporter: dwitte, Unassigned)
References
(Depends on 2 open bugs, Blocks 2 open bugs)
Details
Right now, for converting from ctypes.char.ptr and ctypes.char.array(), we have a readString() function that assumes UTF-8 and gives you back a JS string.
As defined in http://wiki.mozilla.org/Jsctypes/api, we want readString() to take a 'charset' string arg. We then use nsIScriptableUnicodeConverter to do the magic.
We'll need ctypes to expose a JS_SetUnicodeConverter(callbacks) API, which the embeddor (i.e. Gecko) uses to pass in fnptrs to the methods on nsIScriptableUnicodeConverter, or whatever other implementation the embeddor wants. (Since we don't want to drag that implementation into jsengine.)
This is particularly important for Windows, where UTF-8 is not the customary charset.
Reporter | ||
Comment 1•15 years ago
|
||
Also need to implement cdata.writeString() here.
Reporter | ||
Comment 4•14 years ago
|
||
Reassigning to nobody. If anyone wants to work on this, feel free!
Assignee: dwitte → nobody
Comment 5•13 years ago
|
||
I will need both readString and writeString. So, I may take the bug if nobody works on it.
Updated•13 years ago
|
Assignee: nobody → dteller
Comment 6•13 years ago
|
||
My main usage scenario is for streams. With the current specifications, this is not possible, so I will need to make some changes to accommodate incomplete strings.
In my current prototype, when an encoding is supplied, |readString|
- succeeds even if only a prefix of the array/pointer can be converted;
- returns not a |string| but a |String|, with an extra field |bytes_converted|, containing, as you have guessed, the number of bytes in the prefix.
Similarly, I consider the following behavior for |writeString|
- if |length| is supplied, is >0, and not sufficient, throw a |TypeError|;
- if |length| is <=0, if this is a pointer or an array that is too short, |realloc| the buffer.
Comment 7•12 years ago
|
||
Dividing in two bugs, one for readString, one for writeString.
Comment 8•12 years ago
|
||
Plan B: now that bug 763848 has landed, we can implement this as an external C library.
Comment 9•12 years ago
|
||
I am dropping that bug. See bug 770215 for an example of implementing this feature as an external C library.
Assignee: dteller → nobody
Updated•6 years ago
|
Priority: P1 → P5
Updated•2 years ago
|
Severity: normal → S3
You need to log in
before you can comment on or make changes to this bug.
Description
•