• hb_UTF8ToStr

    From Marco Boschi@21:1/5 to All on Mon Jun 20 05:01:39 2022
    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

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Dan@21:1/5 to All on Mon Jun 20 14:05:57 2022
    Il 20/06/2022 14:01, Marco Boschi ha scritto:
    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

    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

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Marco Boschi@21:1/5 to All on Tue Jun 21 01:36:19 2022
    Il giorno lunedì 20 giugno 2022 alle 14:06:00 UTC+2 Dan ha scritto:
    Il 20/06/2022 14:01, Marco Boschi ha scritto:
    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
    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
    Many Thanks Dan

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)