Open Bug 336513 Opened 18 years ago Updated 2 years ago

should have an easy way to create input stream from Unicode string

Categories

(Core :: XPCOM, defect, P3)

defect

Tracking

()

People

(Reporter: dbaron, Unassigned)

Details

[This is spun off of bug 335298 and bug 335342.]

nsIStringInputStream provides an easy way to create an input stream around an ASCII string, and it's quite useful from javascript for little hacks like implementing an about: module.  However, there's not an **equally simple** way to do the same thing for a Unicode string from javascript (or from C++) when dealing with data that are not in an arbitrary encoding.

The fact that it's much easier to do the wrong thing than the right thing is bad -- it should be equally easy, if not easier, to create an input stream from a UTF-8 or UTF-16 string.  (One or the other should be sufficient for C++ callers, since it's easy to convert between the two, and use of AUTF8String in IDL should, I think, make it transparent to javascript callers.)

Note that using UTF-8 actually has some advantages since wrapping a channel around the UTF-16 input stream requires picking the correct choice out of UTF-16BE and UTF-16LE, whereas making the string into an input stream providing UTF-8 doesn't have that problem.
Note that this is NOT about code that deals with data in arbitrary encodings; it's about code that has something that's already an XPCOM Unicode string (UTF-16 or UTF-8, suitable for passing through IDL wstring, AString, or AUTF8String parameters) and wants to wrap that string with an input stream.
Priority: -- → P3
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.