• Visitors can check out the Forum FAQ by clicking this link. You have to register before you can post: click the REGISTER link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. View our Forum Privacy Policy.
  • Want to receive the latest contracting news and advice straight to your inbox? Sign up to the ContractorUK newsletter here. Every sign up will also be entered into a draw to WIN £100 Amazon vouchers!

UTF-8 vs ANSI Character Encoding

Collapse
X
  •  
  • Filter
  • Time
  • Show
Clear All
new posts

    UTF-8 vs ANSI Character Encoding

    G'day techies. I have a question concerning the default encoding of text type files on Windows. Is there a way to specify that all text files created under Windows via a script always have a UTF-8 encoding, or to automatically detect the data type in the file and select the encoding from that.

    So if a file contains UTF-8 type characters, then the file is defined with a UTF-8 encoding, otherwise it is defined as an ANSI file.

    Sorry if that's a bit woolly. Would gladly try to elucidate if required.

    #2
    If the file has a byte-order-mark, then yes, you can detect the encoding.

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

    As usual, .NET has the answer.

    http://msdn2.microsoft.com/en-us/net...aspx#Question2

    Comment


      #3
      Originally posted by DimPrawn View Post
      If the file has a byte-order-mark, then yes, you can detect the encoding.

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

      As usual, .NET has the answer.

      http://msdn2.microsoft.com/en-us/net...aspx#Question2
      How does one go about setting the BOM?

      Comment


        #4
        That's your free 15 minutes used up Moosey. If you would like to use my services, the hourly rate is £60 p.h. which is cheaper than a London Plumber.

        Comment


          #5
          Originally posted by DimPrawn View Post
          That's your free 15 minutes used up Moosey. If you would like to use my services, the hourly rate is £60 p.h. which is cheaper than a London Plumber.
          You sod. Feed me a little bit of info, then reel me in like a nice juicy catch. Couldn't you give me just one little freebie? Please?

          Comment


            #6
            Originally posted by Moose423956 View Post
            You sod. Feed me a little bit of info, then reel me in like a nice juicy catch. Couldn't you give me just one little freebie? Please?
            It's called pre-sales innit?

            Comment


              #7
              Originally posted by oracleslave View Post
              It's called pre-sales innit?
              I hardly think he's going to get a 3-month contract out of it.

              Comment


                #8
                Originally posted by Moose423956 View Post
                How does one go about setting the BOM?
                Use a hex editor. I find dos debug does the job.

                Comment


                  #9
                  Originally posted by Moose423956 View Post
                  You sod. Feed me a little bit of info, then reel me in like a nice juicy catch. Couldn't you give me just one little freebie? Please?
                  http://msdn2.microsoft.com/en-us/library/f5f5x7kt.aspx

                  That's yer lot.

                  Comment


                    #10
                    Originally posted by DimPrawn View Post
                    Thanks DP. I saw this, and thought of you:

                    Visual Basic (Usage)
                    Dim path As String
                    Dim append As Boolean
                    Dim encoding As Encoding

                    Dim instance As New StreamWriter(path, append, _
                    encoding)

                    Comment

                    Working...
                    X