Re: Convert CString to unicode code points
On Feb 4, 10:46 am, Joseph M. Newcomer <newco...@flounder.com> wrote:
It looks like they gave the signed decimal equivalent character (it is wo=
rth observing
that the syntax they've invented is more than a little bad; for example, =
if I have the
Arabic symbol for "1" and want to display it as "1", how can it tell wher=
e the character
code leaves off and the display for non-Unicode readers begin). So I g=
et
-302 FEDE
-307 FECD
-287 FEE1
etc., which according to my Unicode book seem to be Arabic letters, so ar=
e consistent with
your statement that these are going to be Arabic
WideCharToMultiByte with the ANSI code page (which means "prevailing 8-bi=
t language code
page") should indeed display ? for each of these characters, because they=
have no 8-bit
equivalent.
Not sure why you are actually doing WCTMB because it is *supposed* to giv=
e you ?
characters for 1252 (not clear that the ? given in the RTF has any releva=
nce to WCTMB,
just on what reading the RTF file into an 8-bit stream would produce).
What you would do if you really want the hex values of the characters is =
use a CStringW
(which is the default for CString in a Unicode app) and iterate over the =
characters, e.g.,
CString text; // this presumes you are compiling as a Unicode app
c_MyRichEditCtrl.GetWindowText(text);
for(int i = 0; i < text.GetLength(); i++)
{ /* show characters */
CString ch;
ch.Format(_T("%02x"), (WORD)text[i]);
// ch is now something like fee1
// so display ch or do what you want with it
} /* show characters */
=
joe
On Wed, 4 Feb 2009 07:07:05 -0800 (PST), geekgrrl <geekgrr...@hotmail.com=
wrote:
Hello,
I need to display formatted unicode text in a CRichEditCtrl -
specifically Chinese or Arabic characters.
From the RTF specification, I need to write out to the rtf stream the
the following sequence: \uN?, where N represents the Unicode character
value expressed as a decimal number, and the question mark is what non-
unicode enabled readers would use to display the character/.
A snippet of an rtf with proper unicode encoding looks like this:
{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fswiss
\fcharset0 Arial;}}
{\*\generator Msftedit 5.41.21.2508;}\viewkind4\uc1\pard\f0\fs20\u-302?
\u-307?\u-287?\u-290?\u-327?\u-302?\u-318?\u-338?\u-342?\u-345?\u-368?
\u-1131?\u-1132?\u-1135?\u-1234?\u-1231?\u-1228?\par
My question is how do I find the unicode character value for each of
the characters in my CString? My CString is wide, and using
WideCharToMultiByte gives ???? instead of the actual characters, which
is normal as these characters can't be displayed in ANSI on my code
page (1252).
Thanks.
Joseph M. Newcomer [MVP]
email: newco...@flounder.com
Web:http://www.flounder.com
MVP Tips:http://www.flounder.com/mvp_tips.htm- Hide quoted text -
- Show quoted text -
Thanks for the responses, it's a bit clearer to me now. Now my
question is how to convert the FED2 to -302, as that is the string I
need to output to my rtf stream.
Using strol gives me 65234, which is greater than 32767, so I know
this should be output as a negative.