473,320 Members | 1,870 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Unicode to Ansi Conversion

I have written an application which uses a streamwriter to create which is
exported to a third party system. The third party system does not appear to
process the files in its original format. I have identified this as resulting
from the streamwriter outputing in Unicode.

If I open the text file using notepad and save it with the default 'ansi'
type the import works fine. How can I convert the initial file to ansi.

Thanks in advance for any replies!
Jan 23 '08 #1
4 6267
"Gino" <ia*********@twoway-logistics.comwrote in message
news:F3**********************************@microsof t.com...
>I have written an application which uses a streamwriter to create which is
exported to a third party system. The third party system does not appear
to
process the files in its original format. I have identified this as
resulting
from the streamwriter outputing in Unicode.

If I open the text file using notepad and save it with the default 'ansi'
type the import works fine. How can I convert the initial file to ansi.
StreamWriter Constructor (String, Boolean, Encoding)

Dim MyEncoding As Encoding = Encoding.ASCII
Dim f As String = "C:\Temp\SomeFile.txt"
Dim sw As New StreamWriter(f, False, MyEncoding)

sw.Write(LoadsOfCrap)
sw.Close()
Thanks in advance for any replies!
Rude pig.


Jan 23 '08 #2
Gino,

What do you mean with Ansi, all the replies you got where about the ancient
7 bit ASCII code. However that is not Ansi.

Your Unicode is Ansi

http://en.wikipedia.org/wiki/Code_page

You can use the code provided until now in this messagethread, but take than
the proper encoding.

http://msdn2.microsoft.com/en-us/lib...ng(VS.71).aspx

Cor

Jan 23 '08 #3
Gino,

While answering the question from Lorenzo, I remebered that I once had
answered this questiong with this one.

Be aware that this is the American/Dutch code page (it is the only one with
the guilder character in it).

\\\
Dim Str As New StreamReader(FilePath)
Dim arrInput As Byte() = _
System.Text.Encoding.GetEncoding(437).GetBytes(Str .ReadToEnd)
Str.Close()
///

Cor

Jan 23 '08 #4
"Guru" <ru*****@interference.nitschrieb:
>>I have written an application which uses a streamwriter to create which is
exported to a third party system. The third party system does not appear
to
process the files in its original format. I have identified this as
resulting
from the streamwriter outputing in Unicode.

If I open the text file using notepad and save it with the default 'ansi'
type the import works fine. How can I convert the initial file to ansi.

StreamWriter Constructor (String, Boolean, Encoding)

Dim MyEncoding As Encoding = Encoding.ASCII
ASCII != ANSI.

Use 'Encoding.Default' to use the system's default Windows ANSI codepage, or
use 'Encoding.GetEncoding(<codepage number>)' to get a specific Windows ANSI
codepage.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Jan 23 '08 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
by: Thomas Heller | last post by:
I was trying to track down a bug in py2exe where the executable did not work when it is in a directory containing japanese characters. Then, I discovered that part of the problem is in the...
1
by: Paul | last post by:
Hi, I am extending an existing MFC app to use Unicode (for a Japanese version of the interface elements). The app's purpose is to control a peripheral device through the serial port, and the...
18
by: Ger | last post by:
I have not been able to find a simple, straight forward Unicode to ASCII string conversion function in VB.Net. Is that because such a function does not exists or do I overlook it? I found...
40
by: apprentice | last post by:
Hello, I'm writing an class library that I imagine people from different countries might be interested in using, so I'm considering what needs to be provided to support foreign languages,...
4
by: ankan.banerjee | last post by:
Hi, I am currently trying to get an application to support Turkish language... The exact scenario is that we are trying to execute a BULK INSERT query in our MS SQL database based on a data...
9
by: emagzz | last post by:
Hi all, I need to convert many text file from ANSI to UNICODE. Some body knows if there is a free utility that can do this from the command line so as I can use it inside a batch file. ...
6
by: msdnuniv | last post by:
Hello everybody, since days i try to convert Unicode-Strings in VB.NET to ANSI which should be processable in VB6 and converted to unicode again. It should be possible with any codepage, e.g....
2
by: =?Utf-8?B?QWxleCBLLg==?= | last post by:
Hi all My TreeView has unicode and english labels. The treeview shows OK on the screen. When I am trying to get an item's label using TVM_GETITEM API message, the buffer returned by SendMessage...
5
by: =?Utf-8?B?amM=?= | last post by:
Hello, This compiles OK using Multi-Byte character set, but when I switch to Unicode I get an error. char reply = _T("olleh"); I know this will fix the error with the Unicode compile, wchar_t...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.