Hi Glenn, Thanks for the response. However I had read that thread and I must be missing something or have a problem with my system.
Running Rob's example on 15th 12:08, I get the following error: unread escape \d passed through at line27 unread escape \s passed through at line27 and the text in the Richedit control is showing most of the RTF formatting. Pushing the button then just upsets the computer. Running Rob's second example on 17th 11:09, I get the text as intended when the Win32::GUI window loads, and pushing the button gives the following: |A: A These, ?, \x{0131}, are not exactly the letter i \x{263A} |<<48) I'm obviously missing something, but am not sure how this helps my original question. Cheers Chris On Fri, 2005-10-07 at 23:41 -0700, Glenn Linderman wrote: > On approximately 10/7/2005 10:47 PM, came the following characters from > the keyboard of Chris Wearn: > > I am working with UCS2 encoded strings: eg 3114 3116 3127 3119 (Chinese > > in this case). > > > > Is there a way of converting or encoding these pairs, to show their > > Unicode characters in a Richedit control? The obvious, > > > > my $string = pack ("U*", 0x3114, 0x3116, 0x3127, 0x3119); > > > > $re->Text($string); > > > > Does print something, but not the correct representations. > > > > When entering these pairs into Wordpad you have to specify the font > > first. I can also load a Win32::GUI window with a Richedit control, > > change the language setting to Chinese (L-ALT, Shift) and enter the > > pairs into the Richedit control directly, which display correctly. > > > > If you save the text as .RTF and view in notepad, it prefixes the chars > > with lang1028 although the documentation on MSDN doesn't suggest how you > > convert these chars or determine that it is 'lang1028' as opposed to > > 'lang1041' (Japanese). > > > > http://msdn.microsoft.com/library/default.asp?url=/library/en- > > us/dnrtfspec/html/rtfspec_6.asp > > > > Does anyone know if it is possible to interpret the hex pairs and > > determine the language/codepage/conversion to allow the correct > > character to be displayed in the Richedit control? > > > > Is it possible to convert the UCS2 encoded strings to display in the > > Richedit control if they are not based on the default Latin1 codepage? > > You may be interested to first read the thread "RichEdit->Text or > ->GetSelText loses Unicode" that started with a posting by Dan > Dascalescu on July 15, 2005, and then ask followup questions for > anything that you can't figure out, once you have comprehended that > thread. Or of course, questions about comprehending that thread would > also be OK. > > I found that thread to be a great solution for some Unicode problems I > had been having, and Rob provided some great sample code. >