Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

hb_UTF8ToStr

84 views
Skip to first unread message

Marco Boschi

unread,
Jun 20, 2022, 8:01:41 AM6/20/22
to
Hi to all!
I have a program that import into my application some xml files.
Some times I find some strange characters in example I find in my program (console) somethinks like

"Caffè Grande Italia"
and not
"Caffè Grande Italia"


I presume that the function hb_UTF8ToStr resolves this problem because I have some test in a xml file. The question is
What appens if I change a string with hb_UTF8ToStr if is not needed ?(the files is already ansi mode). Does exist a function that tll to me if a file us utf-8 or not?


many thanks to all
marco

Dan

unread,
Jun 20, 2022, 8:06:00 AM6/20/22
to
A couple of C functions easy to implement:

HB_FUNC ( IS_ANSI )
{
LPBYTE pString = ( LPBYTE ) hb_parc( 1 );
WORD w = 0, wLen = hb_parclen( 1 );
BOOL bAnsi = FALSE;

while( w < wLen && ! bAnsi )
{
bAnsi = pString[ w ] >= 224 && pString[ w ] <= 255;
w++;
}

hb_retl( bAnsi );
}

HB_FUNC ( IS_OEM )
{
LPBYTE pString = ( LPBYTE ) hb_parc( 1 );
WORD w = 0, wLen = hb_parclen( 1 );
BOOL bOem = FALSE;

while( w < wLen && ! bOem )
{
bOem = pString[ w ] >= 128 && pString[ w ] <= 168;
w++;
}

hb_retl( bOem );
}

HTH
Dan

Marco Boschi

unread,
Jun 21, 2022, 4:36:21 AM6/21/22
to
Many Thanks Dan
0 new messages