Article View: borland.public.cppbuilder.nativeapi
Article #7283Re: convert char to hex
From: Vladimir Stefanovic
Date: Sat, 26 Feb 2005 22:44
Date: Sat, 26 Feb 2005 22:44
35 lines
1820 bytes
1820 bytes
> I need a function that converts a char to hex.
Look for VCL function: IntToHex(), because
'char' is in fact an 'int'.
> For example
> char ch = convert('A'); //returns 0x41
> ch = convert('B'); //returns 0x42
This is not good. You need 'char*' or 'AnsiString' to
place the result. You cannot place '0x41' in 'char'.
> Does anyone has an example of such function?
You can try something like this /untested/:
#include <SysUtils.hpp>
AnsiString CharToHexNotation( char AChar )
{
return ( "0x" + IntToHex( AChar, 2 ) );
}
void __fastcall TForm1::Button1Click(TObject *Sender)
{
ShowMessage( CharToHexNotation( 'A' ) );
ShowMessage( CharToHexNotation( 'B' ) );
}
--
Best regards,
Vladimir Stefanovic
Technical Details
Message-ID:
<4220fb9f@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!feed5.newsreader.com!newsreader.com!news-out.newsgroups.com!propagator2-sterling.newsfeeds.com!news-in.nuthinbutnews.com!news-in.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mailReferences:
<4220e477$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,e4fa8a59011e3e3c X-Google-Attributes: gid10cc67,public X-Google-Language: ENGLISH,ASCII-7-bit From: "Vladimir Stefanovic" <antivari@po.sbb.co.yu> Newsgroups: borland.public.cppbuilder.nativeapi References: <4220e477$1@newsgroups.borland.com> Subject: Re: convert char to hex Date: Sat, 26 Feb 2005 23:44:01 +0100 Lines: 37 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.2180 X-RFC2646: Format=Flowed; Original X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 NNTP-Posting-Host: 82.117.212.65 Message-ID: <4220fb9f@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1109457823 82.117.212.65 (26 Feb 2005 14:43:43 -0800) Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!feed5.newsreader.com!newsreader.com!news-out.newsgroups.com!propagator2-sterling.newsfeeds.com!news-in.nuthinbutnews.com!news-in.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mail