472,374 Members | 1,399 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

converting ansi to utf8 format - is there anything wrong with it ? urgently requires help

this is a console program to convert ANSI to UTF8 format. Although in
notepad i open the source file (which is ansi), and after running the
program below, and re-open in notepad (it shows utf8 encoding), does it mean
that it has been correctly converted ?

Pls let me know what i have done wrong in conversion ...

Module Module1

Dim args As String() = Environment.GetCommandLineArgs()

Dim line As String

Const newfilename As String = "_utf8"

Sub Main()

Try

If args.Length = 2 Then

Dim sr As StreamReader = New StreamReader(args(1))

Dim SwFromFile As StreamWriter = New StreamWriter(args(1) & newfilename,
False, System.Text.Encoding.UTF8, 512)

Do

line = sr.ReadLine()

SwFromFile.Write(line)

Loop Until line Is Nothing

sr.Close()

SwFromFile.Flush()

SwFromFile.Close()

End If

Catch E As Exception

Environment.Exit(1)

Console.WriteLine("The file could not be read:")

Console.WriteLine(E.Message)

End Try

Environment.Exit(1)

End Sub

End Module

Mar 17 '06 #1
1 3480
"James" <jk****@hotmail.com> schrieb
this is a console program to convert ANSI to UTF8 format. Although
in notepad i open the source file (which is ansi), and after running
the program below, and re-open in notepad (it shows utf8 encoding),
does it mean that it has been correctly converted ?

Pls let me know what i have done wrong in conversion ...

Module Module1

Dim args As String() = Environment.GetCommandLineArgs()

Dim line As String

Const newfilename As String = "_utf8"

Sub Main()

Try

If args.Length = 2 Then

Dim sr As StreamReader = New StreamReader(args(1))


I would pass System.Text.Encoding.Default as the 2nd argument to the
constructor.
Armin

Mar 17 '06 #2

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

Similar topics

3
by: aa | last post by:
Is it OK to include an ANSI file into a UTF-8 file?
4
by: Joseph Suprenant | last post by:
I have an array of unsigned chars and i would like them converted to an array of ints. What is the best way to do this? Using RedHat 7.3 on an Intel Pentium 4 machine. Having trouble here, hope...
2
by: Ziver MALHASOGLU | last post by:
Hi, I produce a text file using my windows application written with c#. -- System.Text.Encoding encOutput=null; encOutput=System.Text.Encoding.UTF8; StreamWriter sw=new...
5
by: scott | last post by:
hi all, hope some one can help me, this prob is driving me mad. im using sockets to communicate between a client and a server. I don't' have control over the client and how it sends the data...
1
by: Tejas | last post by:
Hi, I am using ldap_get_values() call to get the user attributes from LDAP. This call is returning the user attributes in UTF-8 encoding and its a PCHAR*. For normal English characters this...
0
by: Alci | last post by:
I am getting some Korean characters data from MS SQL server. These data were submitted as UTF-8 into the database, but stored as normal varchars. So, when I getting them out of database by using...
9
by: Michael Goerz | last post by:
Hi, I am writing unicode stings into a special text file that requires to have non-ascii characters as as octal-escaped UTF-8 codes. For example, the letter "Í" (latin capital I with acute,...
18
by: Dirk Hagemann | last post by:
Hello, From a zone-file of a Microsoft Active Directory integrated DNS server I get the date/time of the dynamic update entries in a format, which is as far as I know the hours since january 1st...
7
by: firepol | last post by:
Hello there, I am dealing with files encoded in UTF8 and I can't find a way to convert them into ANSI. I've already searched in google for this since a while, and I'm not achieving the result I...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge required to effectively administer and manage Oracle...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific technical details, Gmail likely implements measures...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand. Background colors can be used to highlight important...
0
BLUEPANDA
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS starter kit that's not only easy to use but also...
0
by: Rahul1995seven | last post by:
Introduction: In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python has gained popularity among beginners and experts...
1
by: Johno34 | last post by:
I have this click event on my form. It speaks to a Datasheet Subform Private Sub Command260_Click() Dim r As DAO.Recordset Set r = Form_frmABCD.Form.RecordsetClone r.MoveFirst Do If...
1
by: ezappsrUS | last post by:
Hi, I wonder if someone knows where I am going wrong below. I have a continuous form and two labels where only one would be visible depending on the checkbox being checked or not. Below is the...
0
by: jack2019x | last post by:
hello, Is there code or static lib for hook swapchain present? I wanna hook dxgi swapchain present for dx11 and dx9.
0
DizelArs
by: DizelArs | last post by:
Hi all) Faced with a problem, element.click() event doesn't work in Safari browser. Tried various tricks like emulating touch event through a function: let clickEvent = new Event('click', {...

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.