Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Web and WebWorks Development

Reply
Highlighted
Developer
Posts: 137
Registered: ‎12-22-2010
My Device: Curve 8520
My Carrier: Software Developer

stringToBlob and how to insert a BOM (byte order mark)

[ Edited ]

Hi,

 

I am trying to save a csv file encoded in UTF-8. This CSV needs a byte order mark at the beginning. But I can't get this job done with stringToBlob and saveFile (Webworks API).

 

This is what I tried:

 

blackberry.utils.stringToBlob ("This is some sort of string that I would like to encode", "UTF-8")

 No byte order mark.

 

blackberry.utils.stringToBlob ("\uFEBB\uBF83his is some sort of string that I would like to encode", "UTF-8")

 Wrong byte order mark. I can't see what's calculated wrong but it doesn't make any sense.

 

blackberry.utils.stringToBlob ("\uFEFFThis is some sort of string that I would like to encode", "UTF-16BE")

 Wrong byte order mark. Why? I inserted the right. I get 00 EF 00 BB 00 BF and this is (nearly) the UFT-8 byte order mark ?!?

 

Any ideas whats wrong with my code?