Notifications
Announcements
No record found.
Hi,
i'm sending files to azure blob using Microsoft.Windows.Storage
And when they open it in notepad they get an error because of the currency symbol
So how xan i change it by code to utf-16
Hi IntegrationBeginner,
I think that it should not be the responsibilityof the file sender (who transfers the file from A to B), instead it should be the responsibility of the file creator. Perhaps you can talk with the person/company/developer who created the file and ask them to use UTF-16?
Hi Nikolas,
I created the file by code and send it to azure blob. So when they opened the file they didn't get the correct currency symbol. It's already utf8.. I need to change it utf16
then I guess this issue is not so much related to "sending files to azure blob" but rather the creation of the file. And the relevant part is the code where you create the file. Do you agree?
UTF-8 can represents exactly the same characters as UTF-16, therefore your problem seems to be caused by something else.
Can you please tell us more about your problem with the currency symbol, how you identified the encoding of the file and what code you're using to create file content?
Hi Nikolaos,
Yes true. I'm using commaStreamIo
Hi Martin,
To be honest i don't know that the issue is exactly. But i was told that they weren't able to process the file and that we need to switch that to Utf-16. So myabe the was a problem with the pound symbol or sth.
And i'm using commaStreamIo
Can i change that using commaStreamIo?
If I was you, I would get more information about the problem. It looks likely to me that you (and we with you) are solving a wrong problem. You also can't test your changes if you don't even know how to reproduce the problem.
Anyway, the constructor of TextIo allows you to set the encoding in the third argument. Check out CommaStreamIo - I would expect it to be the same.
Note that according to the documentation, UTF-16 is already the default value for TextIo.
I think they are sure of the problem that their system required UTF-16
it seems we can't set the encoding for commaStreamIo, unless i'm missing sth ( we can't use the new method, and i can only use the static method constructForWrite)
Here's what i'm doing
CommaStreamIo comma = CommaStreamIo::ConstructForWrite(); comma.OutFieldDelimiter('|'); comma.WriteExp(lineContainer); //assume container is filled System.IO.Stream stream = comma.getStream(); stream.Postion = 0; //then i use Microsoft.Windows.Storage to upload the file cloudBlockBlob.UploadFromStream(stream,null,null,null);
Any idea how can i change the UTF8 to UTF-16 based on my code? or what should i do? as it seems there is no code page variable for encoding like textIo
I looked into code and it seems that CommaStreamIo doesn't allow you to set encoding. But you can easily add this capability by yourself - create a child class or add an extension method.
For example:
public static CommaStreamIo constructForWriteWithEncoding(System.Text.Encoding _encoding) { InteropPermission perm = new InteropPermission(InteropKind::ClrInterop); perm.assert(); System.IO.MemoryStream stream = new System.IO.MemoryStream(); System.IO.StreamWriter writer = new System.IO.StreamWriter(stream, _encoding); CommaStreamIo io = new CommaStreamIo(); io.setStream(stream); io.setWriter(writer); return io; }
I can't do an extension class because the new method for commaStreamIo is protected
So i had to create a child class.
However, how can i pass UTf16 to the parameter System.Text.Encoding.. It seems this class has only utf8, utf7 and utf32.
So how can i call the method i created in the child class with utf16?
You're too quick in giving up. You can still use an extension method if you want - just call a factory method and then create and set writer once more:
public static CommaStreamIo constructForWriteWithEncoding(System.Text.Encoding _encoding) { InteropPermission perm = new InteropPermission(InteropKind::ClrInterop); perm.assert(); CommaStreamIo io = CommaStreamIo::constructForWrite(); System.IO.StreamWriter writer = new System.IO.StreamWriter(io.getStream(), _encoding); io.setWriter(writer); return io; }
If you don't know how to use the Encoding class, open the documentation and learn from it. Let me quote it:
UnicodeEncoding encodes Unicode characters using the UTF-16 encoding. Both little endian and big endian byte orders are supported. Also available through the Unicode property and the BigEndianUnicode property.
There are indeed many more properties than the three that you mentioned.
Under review
Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.
As AI tools become more common, we’re introducing a Responsible AI Use…
We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…
These are the community rock stars!
Stay up to date on forum activity by subscribing.
Martin Dráb 559 Most Valuable Professional
André Arnaud de Cal... 464 Super User 2025 Season 2
Sohaib Cheema 250 User Group Leader