CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Jul 2006
    Posts
    21

    how to save file in UTF-16 encoding format in Vb.net

    Hi all,

    In vb.net when we save unicode files by default it is saved in UTF-8 , can any one tell me how to save the files in UTF-16 encoding format...


    Regards

    Gopikris.

  2. #2
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    11,284

    Re: how to save file in UTF-16 encoding format in Vb.net

    I think you can use the StreamWriter :
    Code:
     Dim sw As New IO.StreamWriter("c:\hannes.txt", True)
            MessageBox.Show(sw.Encoding.ToString())
            sw.Close()
    gopala_kris Please do not post the same question over and over again. All questions in this forum deserves a fair chance to get answers, people will answer your question in due time.
    I have removed all the double posted threads.

  3. #3
    Join Date
    Oct 2005
    Location
    Islamabad, Pakistan
    Posts
    1,277

    Re: how to save file in UTF-16 encoding format in Vb.net

    Code:
          Dim sw As New IO.StreamWriter("c:\hannes.txt", True, System.Text.Encoding.UTF32)
            sw.WriteLine("Hello")
            sw.Close()

  4. #4
    Join Date
    Oct 2005
    Location
    Islamabad, Pakistan
    Posts
    1,277

    Re: how to save file in UTF-16 encoding format in Vb.net

    Quote Originally Posted by hannes
    Dim sw As New IO.StreamWriter("c:\hannes.txt", True)
    MessageBox.Show(sw.Encoding.ToString())
    sw.Close()
    this gives the default encoding used by the streamwriter to write into a file, not the encoding used by the file.

  5. #5
    Join Date
    Jul 2006
    Posts
    21

    Re: how to save file in UTF-16 encoding format in Vb.net

    Thank u all

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured