🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #1527

Re: Output special symbol '�'

#1527
From: David M
Date: Fri, 27 Jul 2007 02:07
89 lines
4176 bytes
Just replying to myself - a simpler way might be to use the \x escape 
sequence in a string (I was reminded of this just now, it's in a comment 
about five threads down!) and then painting it using TextOut or something. 
But I'm fairly sure this only works in a Unicode / widechar string literal. 
(I can't find anything about it in the Borland help, only MSDN, so I'm 
guessing as to the behaviour using BC++.)

If you're using the VCL for output you still need to convert your Unicode 
strings to ANSI in the right codepage, as my first post discussed.  You 
could cheat and use a Unicode-aware VCL control too, there are some quite 
good third-party ones.

Finally I think assigning a WideString to an AnsiString performs some kind 
of conversion, but I don't know the details.  I'm pretty certain whatever it 
does is not overly reliable and doing it manually gives better results, but 
I honestly don't know.

Cheers,

David



"David M" <vintagedave@gmail.com> wrote in message 
news:46a95084@newsgroups.borland.com...
> >Is there any function to map this diameter symbol to any font?
>>What must be set on programmatically so that I do not depend on the 
>>default font.
>
> The best thing to do would be to use the Unicode character (U+00D8 for the 
> capital, U+00F8 for lowercase) and map it into something useable at 
> runtime. Note that there's no guarantee that a Unicode character really 
> can be mapped to a character in a specific codepage, so you may want to 
> have a fallback character to use in the worst case (eg, 'd' or something.)
>
> I'd suggest you look at using ::WideCharToMultiByte, probably passing in 
> CP_THREAD_ACP for the codepage.  For example, using a buffer called szAnsi 
> large enough to hold the conversion results (note it's a string, not a 
> character, even if in practice here you're only converting one character),
>
>   const WideString strSymbol(static_cast<wchar_t>(0xF8));
>   int iSize(WideCharToMultiByte(CP_THREAD_ACP, 0, strSymbol.c_bstr(), 1, 
> szAnsi, iBUFFER_SIZE, NULL, NULL));
>   if (iSize == 0) {
>      // conversion failed, return your fallback character
>   } else {
>      // return a std::string or AnsiString based on szAnsi
>   }
>
> Codegear will be bringing out a Unicode-enabled VCL next year, so soon 
> stuff like this will be a thing of the past.
>
> Hope this helps,
>
> Cheers,
>
> David
>
>
> "Renald Yazmir" <renald@partmaker.com> wrote in message 
> news:46a775e8$1@newsgroups.borland.com...
>> Hello,
>>
>> I am trying to output a diameter symbol '�'
>>
>> I defined it as
>>
>> #define DIAMETER_SYMBOL  '�'
>> and then I strcpy or strcat it to my output text. It works well.
>>
>> But on some computers diameter symbol is not recognized by the default 
>> font. It appears as
>> something else. My guess is that default font on that computer does not
>> support this character.
>> Is there any function to map this diameter symbol to any font?
>>
>> What must be set on programmatically so that I do not depend on the 
>> default font.
>> Or any other solution.
>>
>>
>>
>> Thank you
>>
>> Rony
>>
>>
>
> 
Technical Details
Message-ID: <46a95365@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news2.google.com!news4.google.com!feeder1-2.proxad.net!proxad.net!feeder1-1.proxad.net!feeder.news-service.com!newsfeed.freenet.de!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <46a775e8$1@newsgroups.borland.com> <46a95084@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,1952c98cce84cd99
X-Google-Attributes: gid10cc67,public,usenet
X-Google-Language: ENGLISH,ASCII
From: "David M" <vintagedave@gmail.com>
Newsgroups: borland.public.cppbuilder.nativeapi
References: <46a775e8$1@newsgroups.borland.com> <46a95084@newsgroups.borland.com>
Subject: Re: Output special symbol '�'
Date: Fri, 27 Jul 2007 12:07:35 +1000
Lines: 91
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.3138
X-RFC2646: Format=Flowed; Response
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3138
NNTP-Posting-Host: 203.24.135.146
Message-ID: <46a95365@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1185502053 203.24.135.146 (26 Jul 2007 19:07:33 -0700)
Path: arc1-ca.pugleaf.net!g2news2.google.com!news4.google.com!feeder1-2.proxad.net!proxad.net!feeder1-1.proxad.net!feeder.news-service.com!newsfeed.freenet.de!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail