Easy Unicode


I was given a very simple task at work: Take a dialog box that acts as a registration page with a few registration fields (edit boxes), and convert it to support Unicode. This means that the entered data is wide characters. This data of course must be dealt with and should be (in my case) sent to a server. So? Easy isn't it?

I looked it up, studied the concept of Unicode, and?!?!? NADA! You can easily change the character set of your project to Unicode, but who is crazy enough to do that? You will waste lots of time altering your whole code to fit a Unicode character set. You might even end up rewriting your whole code... I could not find an easy or simple way of doing it otherwise. All the solutions I could find contained pages of useless or irrelevant code.

After some research, I came up with a simple and elegant solution that I share here, and I hope it might help someone's project or save some people a very large headache. This article includes code samples and a complete downloadable project (Unicode.zip) that you can compile and play with. In addition, the compiled sample application (Unicode_app.zip) is downloadable as well.

My Solution

Use a Rich Edit-Box Control (CRichEditCtrl) instead of an Edit-Box Control (CEdit). Please note that, to use a rich edit control, you must call AfxInitRichEdit() at the initialization of your application. This function initializes the rich edit control (see the AfxInitRichEdit MSDN documentation regarding rich edit box versions). Now, use SendMessageW to send your text to or from the rich edit box.

What SendMessageW Is

#ifdef UNICODE
#define SendMessage SendMessageW
#define SendMessage SendMessageA
#endif    //!UNICODE

SendMessageW is actually the Unicode instance of SendMessage. If you compile your code with a Unicode character set, SendMessageW is used. Otherwise, SendMessageA is used. You actually want to enforce the usage of the Unicode version of SendMessage without a definition of UNICODE, so you call SendMessageW directly. How do you use SendMessageW? Well, the same way you use SendMessage, but you need to remember that all the function's parameters are Wide Character now (Unicode).

How to Use It

Following is an example code (I used it in Unicode.exe) for the usage of Unicode in a non-Unicode (ANSI) application:

void CUnicodeDlg::OnCopy()
   LRESULT lResult;
   WCHAR lParam[100]      = {0};
   wParamIN.cb            = (this->m_rich1.
   wParamIN.flags         = GT_RAWTEXT;
   wParamIN.codepage      = 1200;
   wParamIN.lpDefaultChar = NULL;
   wParamIN.lpUsedDefChar = NULL;
   wParamOUT.codepage     = 1200;
   wParamOUT.flags        = ST_SELECTION;

   // handle to source control
   lResult = SendMessageW(this->m_rich1.m_hWnd,
                          // message ID
                          // = (WPARAM) () wParam
                          (WPARAM) &wParamIN,
                          // = (LPARAM) () lParam
                          (LPARAM) lParam);

   MessageBoxW(this->m_hWnd, lParam, L"Here we go...",

   // handle to destination control
   lResult = SendMessageW(this->m_rich2.m_hWnd,
                          // message ID
                          // = (WPARAM) () wParam
                          (WPARAM) &wParamOUT,
                          // = (LPARAM) () lParam
                          (LPARAM) lParam);

How to Use Unicode.exe

My simple application (Unicode.exe) simply demonstrates entering a Unicode string into a rich edit box of a non-Unicode application and copying it to another rich edit box. You can use the Windows Character Map (Start->Programs-> Accessories->System Tools) to get Unicode symbols.

Paste the copied symbols in the Input rich edit box of the Unicode.exe.

Click Copy. A message box with the input string is shown. Click OK.

The entered Unicode string is copied to the Output rich edit box.


In my sample application, I used lParam as a wide character parameter to contain the Unicode string. You can keep using it to send its content forward, but always remember that it contains Unicode formatted data, meaning that each character/symbol takes twice the memory size.

I hope I could help. Enjoy.

About the Author

Lior Peretz

I'm a developer in Aladdin Ltd. at the Software DRM R&D.



  • Rose défriser les cheveux en édition limitée ghd vente chaude à Oslo

    Posted by pdypfj151 on 07/16/2013 02:30am

    The Amazing GHD Rich Ruby Red Metallic Collection cadeau vous définissez l'un des trois nouveaux Samlinger utgitt dans le cadre d'Metallic utvalg de GHD, pour Noël 2012. Il a donné vakre vu à l'intérieur de maison SUVEREN GHD Gold Classic Styler, dans un "Ruby Red Rich" effet finish.Advanced ovn technologie céramique métallique pour les résultats complets lisses, brillants. Tension universelle pour ytelse cohérente atteint Reiser. Plater noir élégant avec et SNEV de Gnisten pour le style ulempe-libre. Vink Lede plaqueur pour enklere Kröller og Bolger. Ekstra Tuyau ligne de crédit renouvelable 2.7m pour la liberté pendant styling.It vous egnet pour les types de cheveux alle [url=http://bbeatsinorge.cabanova.com/]ghd lisseur pas cher[/url] Lisseur céramique chaleur plus uniforme que les redresseurs métalliques et la distribution de chaleur permet un style orienté lisse. Redresseurs en céramique ne sont pas aussi sujettes à l'écaillage ou de fissuration comme redresseurs de métal et de verre. Pour profiter des avantages de votre lisseur en céramique pour une longue période, nettoyez les plaques en céramique. Une accumulation de laque et d'autres produits de coiffage peut aussi affecter votre style de cheveux. Nettoyage des plaques en céramique ne nécessitent que quelques produits et quelques minutes de votre time.So comment nettoyer un GHD Styler? [url=http://bbeatsinorge.cabanova.com/]ghd pas cher[/url] Défrisants GHD stylers sont tous azimuts comme forlater cheveux incroyablement joliment et beundringsverdig. Ces elementene est tellement portable et a noen egenskaper qui les rend difficiles agréable voyage de la rivière avec ou transporter. Dessuten rend tige droite, un bon cadeau pour un Kvinne sur bursdag sien et devient vraiment verdsatt av tout comme Mottar comme un cadeau. Noen Surprise confortables bursdag sienne avec GHD Ensemble-cadeau précieux.

  • Crucial sales exorbitant distinction of headphones aside Dr Dre

    Posted by motherdhmm on 06/04/2013 03:06am

    [url=http://www.headphonescheaponlineaustralia.com/]beats by dre[/url] The right to Monster Beats Solitary headphones: The Beats Solitary by Dr. Dre Headphones from Horribleness present a smart, small, and dependable forge that lends itself well to on-the-go use.The mooring is ultranice and features an integrated mic, iPod controls, and volume rocker.Bass is massive, and the carton includes a at one's fingertips carrying case. because of its undersized evaluate, easy to perform, so the unseasoned materials needed in the production process more in the stock exchange prices were rather base, cheaper then Beats through Dr. Dre Studio Diamond Headphone the Red in Australia, as long as you have 150USD that, you can not the entrain it from the Beats about Dr. Dre online. [url=http://www.headphonescheaponlineaustralia.com/dre-beats-solo-hd-c-66_68_77.html]Dre beats solo HD[/url] In Australia more and more people are using the Beats past Dre, by manipulate the this of Brute Beats is not one can trample depart your heart with its sympathetic organ But also you determination submerge yourself into a music exultant! When you¡¯re compassionate down musiccan afford you enthusiasm. Wonderful music can forward you to make every effort after difficult situations. Modern Style Beats By Dr.Dre built the area famous technology and flawless pulsation of the suggestion of the orator, solos in the clarification incline and folds to by far accumulate, butstill victual an unlikely accuracy of sound. Awfulness Beats By means of Dr Dre Transaction marked down with a stalwart bass, still linger in our ears. [url=http://www.headphonescheaponlineaustralia.com/dre-beats-solo-hd-c-66_68_77.html]Dre beats solo HD[/url] Music can entrust people some disparate feelings.When you pay attention to to music, you determination fix it peacefulness of recollection and happy.So, we notion of you will-power need some charitable headphone or earphone.We regard as you on attachment our righteousness headphone or earphone.

  • Stil og design ense deres øyne

    Posted by mantouhmmm on 06/03/2013 08:52pm

    [url=http://www.beatsbydrestudio.moonfruit.com/]beats by dre studio[/url] Musikk og filmer er også et godt valg for mødre som er interessert i det. Den aller beste av de og CDer kan passe inn i hennes gave kurv. Klassiske samlinger og også sanger annonse filmer fra barndommen kan faktisk gjøre henne oppriktig glad og gjøre henne gå tilbake igjen til tidligere tider. Du kan også bestemme sanger eller filmer som du har et minne med henne. Eller bare, gave henne med et utvalg av hennes favoritt movies.Chocolates og søtsaker er også et godt valg. For den saks skyld, kan du fylle gave kurv med hennes favoritt måltider stuffs eller en ting som hun ofte ønsket å ha og kunne aldri ha det. For mødre som liker hagearbeid, ikke nøl. Gå for de fineste frø eller gå for stiklinger av vakre blomster eller grønnsaker som gjør hennes hage fantastisk. [url=http://www.drebeatsnorge.qsite.dk/]beats by dre norge[/url] Lav overflod er fortsatt Studio fokus - forutsatt tiltalende akseptabelt i lav frekvens. Ikke som Tour, er Flat lav overflod tykkere og enklere, ingen overdriver bottomward men bare affære behovene til musikk som Hip-Hop. Topp overflod er en av de aspektene som vi aksepterer kritisert on Tour - det er for aciculate og ikke omgjengelige i det hele tatt. Mens Flat betaler ekstra absorpsjon til antitese og lav overflod - litt "overkompensasjon" på toppen frekvens, motvektstrucker og litt defekt av detaljer. Derfor er som en dyktig Flat artikulasjon sentrert i gjennomsnittlig overflod og lav overflod som ikke er faktisk akseptabelt for som liker flammer akutt stemme. På slutten av artikkelen, anerkjennelse jeg hotsalesmart.com til deg, Monster beats by dr. dre flat alene er $ 169 til $ 219 for chargeless forsendelsen hjem. [url=http://www.drebeatsbysnorge.blinkweb.com/]beats by dre norge[/url] Internett er et sted der flere og flere produsenter og slo beslutningstakere samles for å tillate nye artister til å komme og kjøpe sine beats. Det er hundrevis og hundrevis av beat-selger nettsteder på nettet som imøtekomme til kunstnere som har talent, men kan ikke ha et veldig stort budsjett til å kjøpe instrumentaler. Med det blir sagt, er det også mange beat-nettsteder som ikke er satt opp riktig, og kan lage musikk artist nest gjette når det kommer til å kjøpe en instrumental fra noen av disse sites.First du må være i stand til å finne en "FAQ" side på en beat nettsted for å besvare noen av dine spørsmål du måtte ha om du er usikker på noe som er markedsført på nettsiden. Du bør være i stand til å lese alt klart og presist. Hvis du har noen spørsmål bør det være en måte å komme i kontakt med produsenten av Beats By Dre Mixr

  • oakley outlet provide discount oakley sunglasses for cheap

    Posted by heterlife on 05/07/2013 08:51pm

    Take care when purchasing Oakley glasses from unverified locations.You may find out a design of reading throughfor these stores. [url=http://www.test.com/]cheap test holbrook[/url] Along with the second 1 is one of the two styles in Ray-Ban new Carbon Fiber Collection-the rectangular design.Bear in mind the following whenever impressing folks is often a matter the particular Ray Ban THUMP could hardly are more capable of the job. [url=http://www.test.com/]fake test sunglasses[/url] In fact, Ray Ban sunglasses don't turn into globe renowned until eventually the second Globe War when US military have been in will need of some special protective eye wear.Transitions Optical Inc. [url=http://www.test.com/]fake tests[/url] The high-tech material-Carbon Fiber the is main cause I create this piece into my list.Others might make an effort to make an impression on people who have only a developer's brand but the individual wearing of the group of Ray Ban Split Beat sunglasses may download favored songs within their eye wear. [url=http://www.test.com/]knock off test sunglasses[/url] What's astounding here is the ease with which we put our eyes at risk; those eyes that will make us see all colors of the world.These meet as well as exceed ANSI safety specifications. [url=http://www.test.com/]cheap test holbrook[/url] Ray ban are typically liked and praised it really is scarcely shocking they've grow to be desired and distinguished through the several persons in all avenues of life.She's it from him when she see Ray Ban Sunglasses picture about the letter.

  • Nike Air Max 1 FB publicity, father a fervent color grain, the new shoes

    Posted by Geozyoceada on 04/22/2013 08:47pm

    In the summer in a goblet interior the chilling sprite seems to be a wholesome preferred, but if the sprite "feet"? Will also give you a frisk, get a invigorating! This summer, Nike and Sprite [url=http://fossilsdirect.co.uk/glossarey.cfm]nike huarache[/url] and his sneakers to a fuse of enduring snow spread of green, white and indecent color system in the definitive Nike Arrogance Max 1 shoes let slip a food presumptuous scent.[url=http://markwarren.org.uk/property-waet.cfm]air max 90[/url] Summer is the yet to hand-pick a purified shoe, shoes should be a good choice. Qualifying series Nike Air Max HomeTurf megalopolis recently definitely comes up, this series in the immortal Breath Max shoes to London, Paris and Milan the three paid eulogy to the iconic megalopolis of Europe, combined with the characteristics of the three cities, Feeling Max 1 HYP,Allied Max 90 HYP,Connected Max 1 and shoes such as Make public Max 95, combined [url=http://fossilsdirect.co.uk/glossarey.cfm]nike huarache[/url] with the Hyperfuse, as marvellously as a variety of materials, such as suede, Whether you hankering functional or retro-everything.

  • Lightweight smart – Nike Unshackled TR Attack in shoot up 2013 3 series

    Posted by Tufffruntee on 04/19/2013 05:53am

    Nike Free TR Trim 3 noteworthy features is to exploit the additional plot: Nike Free 5 soles improved bending Scratch; stylish tractor layout making training more focused when; lighter preponderance, the permeability is stronger, and more smart shoe designs not not make shoes [url=http://northernroofing.co.uk/roofins.cfm]nike free run 3[/url] more serene wearing, barefoot training feel, but also more stylish appearance. Nike Relieve TR Fit 3 provides supreme lateral reliability, you can have the legs in the untenable during training. Diligent vamp nobles breathable webbing, drop foam's one of a kind lay out can be [url=http://northernroofing.co.uk/roofins.cfm]nike free run 3[/url] seen under the aegis it. Lightweight, ragged, reduce foam material occupied by completely occasional seams, more obedient, support is stronger. Need more help, role of a training utilize, foam close in more parts of the need for conformableness, effervescence loose. Throw away twice say nothing moisture wicking synthetic materials, vapid on your feet, mitigate living feet sear and comfortable. Phylite [url=http://markwarren.org.uk/goodbuy.cfm]nike free[/url] midsole offers lightweight shock unchanging, famous durability and sedate outsole can do to greatly turn the all-embracing weight of the shoe. Qianzhang pods on the outsole and heel-shaped Unripened rubber enhances the shoe multi-directional purchase on sundry surfaces.

  • oakley sunglasses discount

    Posted by pgliliImpumpdzr on 03/29/2013 09:56am

    http://guccisunglassescheap.webs.com - ray ban sunglasses cheap discount sunglasses http://wholesalesunglasseschic.webs.com - wholesale oakley sunglasses cheap oakley http://discountsunglassesfinewebs.com - discount ray ban discount sunglasses http://wholesalesunglassescool.webs.com - wholesale oakley sunglasses wholesale sunglasses http://guccicheapsunglass.webs.com - cheap ray ban fake oakley sunglasses

  • womens chemise

    Posted by Fishnethg1076 on 03/29/2013 07:47am

    http://Lingeriesv.webs.com - white LingerieThe babydoll was an instant classic upon its release, and remains one to this day The installation went smoothly, and we had him up and running in short order http://G-string.webs.com - Sexy ChemiseThose with large bosoms might prefer fitting designs that can be achieved with stretching synthetic materials that can be flexible to make them appear slimmer with a tighter, smoother finishDreamgirl is actually recognised as the leading marketer and manufacturer of sexy lingerie http://sexycostumesa.webs.com - Sexy cop costumeHalloween is undoubtedly a children's holiday The basic difference is that baby doll lingeries range between the upper thigh and the belly button in length, while baby doll dresses are slightly longer in length http://babydollnightgowns.webs.com - Babydoll lingerieGet into character and go with it Meanwhile, light green and dark green brings different meaning http://sexystockings.webs.com - Fishnet BodystockingsHowever, the item has also continued to evolveHowever, contrasting most other child mermaid costumes that are generally based on the blue-green colors of the sea, the Barbie costume comes in Barbie's favorite color, pink

  • sunglasses wholesale

    Posted by bgliliImpumpnia on 03/29/2013 01:37am

    fake ray ban sunglasses [url=http://akeoakleysunglasses.webs.com]fake ray ban sunglasses[/url] cheap ray ban wayfarer discount ray ban [url=http://discountsunglassessale.webs.com]discount ray ban[/url] replica ray ban designer sunglasses cheap [url=http://sunglassdicountsaleu.webs.com]designer sunglasses cheap[/url] discount ray ban cheap sunglasses [url=http://sunglasspomoteauthentic.webs.com]cheap sunglasses[/url] cheap wayfarer sunglasses discount ray ban [url=http://discountsunglasseshoo.webs.com]discount ray ban[/url] oakley discount cheap oakley frogskins [url=http://sunglasswholesaleofgucci.webs.com]cheap oakley frogskins[/url] cheap sunglasses,,, wholesale sunglasses [url=http://wholesalesunglassescool.webs.com]wholesale sunglasses[/url] cheap ray ban sunglasses replica oakleys [url=http://replicaguccisunglasses.webs.com]replica oakleys[/url] wholesale sunglasses

  • wholesale baseball caps

    Posted by xxds6on on 03/29/2013 01:29am

    [url=http://snapbackswholesalezone.webs.com]hats wholesale[/url] hats wholesale y zkkr [url=http://snapbackhatwholesale.webs.com]wholesale fitted hats[/url] wholesale fitted hats w zkvg[url=http://cheapsnapbackshat.webs.com]cheap hats online[/url] cheap hats online k yvxu[url=http://goodsnapbackhatscheap.webs.com]cheap snapbacks[/url] cheap snapbacks p tdwq[url=http://cheapsnapbacksforsalezone.webs.com]snapback hats cheap[/url] snapback hats cheap u cpxh[url=http://cheapsnapbacksforsalezone.webs.com]snapback hats cheap[/url] snapback hats cheap u xoaq [url=http://cheapsnapbacksforsalezone.webs.com]cheap snapbacks online[/url] cheap snapbacks online w xjwk [url=http://cheapsnapbackshat.webs.com]cheap hats online[/url] cheap hats online b kkpa[url=http://goodsnapbackhatscheap.webs.com]cheap snapbacks[/url] cheap snapbacks a pnev[url=http://snapbackhatwholesale.webs.com]wholesale beanies[/url] wholesale beanies d kfvu[url=http://cheapsnapbacksforsalezone.webs.com]snapback hats cheap[/url] snapback hats cheap i eoyp[url=http://snapbackswholesalezone.webs.com]hats wholesale[/url] hats wholesale x cnfz [url=http://cheapsnapbacksforsalezone.webs.com]cheap snapbacks for sale[/url] cheap snapbacks for sale x kmvp [url=http://wholesalefittedhat.webs.com]wholesale fitted hats[/url] wholesale fitted hats t yxqz[url=http://snapbackswholesalezone.webs.com]hats wholesale[/url] hats wholesale n jrtq[url=http://cheaphatsmall.webs.com]cheap snapback hats[/url] cheap snapback hats z vvgd[url=http://snapbackswholesalezone.webs.com]snapbacks wholesale[/url] snapbacks wholesale g evjf[url=http://cheaphatsmall.webs.com]cheap snapback hats[/url] cheap snapback hats o sbkf

  • Loading, Please Wait ...

Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • Entire organizations suffer when their networks can't keep up and new opportunities are put on hold. Waiting on service providers isn't good business. In these examples, learn how to simplify network management so that your organization can better manage costs, adapt quickly to business demands, and seize market opportunities when they arise.

Most Popular Programming Stories

More for Developers

RSS Feeds

Thanks for your registration, follow us on our social networks to keep up-to-date