🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Output special symbol '�'

#1526
From: David M
Date: Fri, 27 Jul 2007 01:55
62 lines
2890 bytes
>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: <46a95084@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news2.google.com!news1.google.com!news.glorb.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail
References: <46a775e8$1@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>
Subject: Re: Output special symbol '�'
Date: Fri, 27 Jul 2007 11:55:20 +1000
Lines: 64
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: <46a95084@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1185501316 203.24.135.146 (26 Jul 2007 18:55:16 -0700)
Path: arc1-ca.pugleaf.net!g2news2.google.com!news1.google.com!news.glorb.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail