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
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. MultiByteWideChar and € (Euro sign)

MultiByteWideChar and € (Euro sign)

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

    The following string encoded in UTF8 "s in €" appears in ascii as "s in €" after a call to MutiByteToWideChar

    int nSize = MultiByteToWideChar(CP\_UTF8,0,pstrValue,-1,NULL,0);
    if ( nSize == 0 )
    	return;
    
    WCHAR \* pBuffer= new WCHAR\[nSize\];
    MultiByteToWideChar(CP\_UTF8,0,pstrValue,-1,pBuffer,nSize);
    

    unfortunately instead of the Euro sign, I get the character #26 Any idea? Thanks

    Y 1 Reply Last reply
    0
    • B BadJerry

      The following string encoded in UTF8 "s in €" appears in ascii as "s in €" after a call to MutiByteToWideChar

      int nSize = MultiByteToWideChar(CP\_UTF8,0,pstrValue,-1,NULL,0);
      if ( nSize == 0 )
      	return;
      
      WCHAR \* pBuffer= new WCHAR\[nSize\];
      MultiByteToWideChar(CP\_UTF8,0,pstrValue,-1,pBuffer,nSize);
      

      unfortunately instead of the Euro sign, I get the character #26 Any idea? Thanks

      Y Offline
      Y Offline
      YoungJin Shin
      wrote on last edited by
      #2

      Do you check the utf8 values in pstrValue are correct? Correct utf8 value for Euro sign is "0xe2, 0x82, 0xac". Also, if you check the pBuffer using C runtime function like printf, you should set locale properly before calling printf through setlocale function. I test your code but it runs correctly.

      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