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 / C++ / MFC
  4. Reading Unicode Values from INI file

Reading Unicode Values from INI file

Scheduled Pinned Locked Moved C / C++ / MFC
question
5 Posts 2 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.
  • K Offline
    K Offline
    krishnakumartm
    wrote on last edited by
    #1

    Hi, I hanve a ini file with the UNICODE entries like chinese characters, i need to read the values and write it back to ini file. How can i read and write the unicode strings from and to INi file. Thanks in advance

    ---------------------------- KRISHNA KUMAR T M

    K N 2 Replies Last reply
    0
    • K krishnakumartm

      Hi, I hanve a ini file with the UNICODE entries like chinese characters, i need to read the values and write it back to ini file. How can i read and write the unicode strings from and to INi file. Thanks in advance

      ---------------------------- KRISHNA KUMAR T M

      K Offline
      K Offline
      krishnakumartm
      wrote on last edited by
      #2

      I tried withe GetPrivateProfileStringW, which is not reading properly.

      ---------------------------- KRISHNA KUMAR T M

      1 Reply Last reply
      0
      • K krishnakumartm

        Hi, I hanve a ini file with the UNICODE entries like chinese characters, i need to read the values and write it back to ini file. How can i read and write the unicode strings from and to INi file. Thanks in advance

        ---------------------------- KRISHNA KUMAR T M

        N Offline
        N Offline
        norish
        wrote on last edited by
        #3

        Is the ini file mixed with ANSI and UNICODE? Then, if UNICODE means UTF-8, it may be solved by MultiByteToWideChar and WideCharToMultiByte, I think. When UNICODE means UTF-16, I dont have any good idea, sorry. If the ini file is all UTF-16 encoding with BOM, GetPrivateProfileStringW and WritePrivateProfileStringW could not help you?

        K 1 Reply Last reply
        0
        • N norish

          Is the ini file mixed with ANSI and UNICODE? Then, if UNICODE means UTF-8, it may be solved by MultiByteToWideChar and WideCharToMultiByte, I think. When UNICODE means UTF-16, I dont have any good idea, sorry. If the ini file is all UTF-16 encoding with BOM, GetPrivateProfileStringW and WritePrivateProfileStringW could not help you?

          K Offline
          K Offline
          krishnakumartm
          wrote on last edited by
          #4

          Yes the Ini file is the mixture of ANSI and UNICODE. The file format is also in the UTF-8. How the MultiByteWideChar will help, is this is th way? 1.Use GetPrivatePrfileString. 2.Convert the buffer using WideCharToMultiByte.

          ---------------------------- KRISHNA KUMAR T M

          N 1 Reply Last reply
          0
          • K krishnakumartm

            Yes the Ini file is the mixture of ANSI and UNICODE. The file format is also in the UTF-8. How the MultiByteWideChar will help, is this is th way? 1.Use GetPrivatePrfileString. 2.Convert the buffer using WideCharToMultiByte.

            ---------------------------- KRISHNA KUMAR T M

            N Offline
            N Offline
            norish
            wrote on last edited by
            #5

            char szUtf8[LINE_SIZE];
            int n = GetPrivatePrivateStringA("section", "key", "", szUtf8, LINE_SIZE, "inifile.ini");
            DWORD flags = 0; // some conversion option here
            int n2 = MultiByteToWideChar(CP_UTF8, flags, szUtf8, -1, NULL, 0);
            // ...allocate buffer
            MultiByteToWideChar(CP_UTF8, flags, szUtf8, -1, pUtf16, n2);

            Above code can work? (I did not check this with real code yet) Good luck :)

            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