Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. UTF7, UTF8, ASCII ..... I have problems

UTF7, UTF8, ASCII ..... I have problems

Scheduled Pinned Locked Moved C#
csharphelpquestion
5 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    Rostrox
    wrote on last edited by
    #1

    Hello: I have the next C# code: r = new StreamReader("300_46C_UST04.txt", System.Text.Encoding.UTF7) l = r.ReadLine() The input file has the next data: 123+ABC3210_áéíóúñÑ\/ÁÉÍ-- After reading the record, variable "l" has: 123?_áéíóúñÑ\/ÁÉÍ-- It ignored the +ABC3210!! UTF is the best option for special characters such as Ñ, ñ, etc., but when the string has the character "+" .... it is terrible. What Am I doing bad? I tried all the possibilities (with unicode, ascii, UTF8) but I have different results. When I delete the second parameter, i.e. System.Text.Encoding.UTF7, I obtain the next result: 123+ABC3210_\/-- (special characters where ignored!!) Really, I do not understand. Please .... a help?

    S 1 Reply Last reply
    0
    • R Rostrox

      Hello: I have the next C# code: r = new StreamReader("300_46C_UST04.txt", System.Text.Encoding.UTF7) l = r.ReadLine() The input file has the next data: 123+ABC3210_áéíóúñÑ\/ÁÉÍ-- After reading the record, variable "l" has: 123?_áéíóúñÑ\/ÁÉÍ-- It ignored the +ABC3210!! UTF is the best option for special characters such as Ñ, ñ, etc., but when the string has the character "+" .... it is terrible. What Am I doing bad? I tried all the possibilities (with unicode, ascii, UTF8) but I have different results. When I delete the second parameter, i.e. System.Text.Encoding.UTF7, I obtain the next result: 123+ABC3210_\/-- (special characters where ignored!!) Really, I do not understand. Please .... a help?

      S Offline
      S Offline
      Steven Campbell
      wrote on last edited by
      #2

      What encoding is the file actually in? Did you create it? If the file is in a certain encoding, you can get strange results when you read it with other encodings. Things get really crazy when unicode is involved, because there is not a simple 1 byte = 1 character mapping, especially when dealing with "special characters.


      my blog

      R 1 Reply Last reply
      0
      • S Steven Campbell

        What encoding is the file actually in? Did you create it? If the file is in a certain encoding, you can get strange results when you read it with other encodings. Things get really crazy when unicode is involved, because there is not a simple 1 byte = 1 character mapping, especially when dealing with "special characters.


        my blog

        R Offline
        R Offline
        Rostrox
        wrote on last edited by
        #3

        Hello Steven: Thanks for your attention. The input file was generated using notepad and I do not know the encoding used. Where can I check that? in my W2K parameters? I live in Bolivia, South America, where Ñ, ñ, á ... etc. are very common. I am very concerned about this problem because, I made many, many programs that read .txt information to load to a database and I fear that many of this spanish characters were lost. My God ... I never imagine this kind of problem. My head (and my ass) are involved!! What do you think I can do? Best regards

        M E 2 Replies Last reply
        0
        • R Rostrox

          Hello Steven: Thanks for your attention. The input file was generated using notepad and I do not know the encoding used. Where can I check that? in my W2K parameters? I live in Bolivia, South America, where Ñ, ñ, á ... etc. are very common. I am very concerned about this problem because, I made many, many programs that read .txt information to load to a database and I fear that many of this spanish characters were lost. My God ... I never imagine this kind of problem. My head (and my ass) are involved!! What do you think I can do? Best regards

          M Offline
          M Offline
          mav northwind
          wrote on last edited by
          #4

          You could try using System.Text.Encoding.Default for reading the file. Because this uses the current system code page you should be able to read in files that have been written by other applications that are not concerned about encoding. Regards, mav

          1 Reply Last reply
          0
          • R Rostrox

            Hello Steven: Thanks for your attention. The input file was generated using notepad and I do not know the encoding used. Where can I check that? in my W2K parameters? I live in Bolivia, South America, where Ñ, ñ, á ... etc. are very common. I am very concerned about this problem because, I made many, many programs that read .txt information to load to a database and I fear that many of this spanish characters were lost. My God ... I never imagine this kind of problem. My head (and my ass) are involved!! What do you think I can do? Best regards

            E Offline
            E Offline
            eggie5
            wrote on last edited by
            #5

            Notepad saves in ASCII. /\ |_ E X E GG

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups