Hi Miguel,

Thank you for your suggestions and code.

I realize it is possible to get UNICODE string from GetValue RDD method, 
then bypass all the xHarbour infrastructure built over the years by 
hundreds of developers and display it on the screen using TextOutW or 
similar Windows API function. In this approach the xHarbour runtime is 
reduced to RDD delivering the string. We cannot use such string in 
expressions, comparisons, we cannot use dbEdit() or similar browsing 
functions, we cannot use GTWIN which will not handle the output of 
UNICODE strings.
The application in question is a text-based application and it needs to 
use GT, or otherwise it needs to be rewritten.

With proper UNICODE implementation, using text-based application which 
_concurrently_ use many languages would be completely transparent and 
woudn't require app rewriting or even worrying about codepages used. 
What I mean:

1. String is stored in Oracle (or other database - even modified DBF) as 
UNICODE
2. It is delivered to application from GetValue RDD method as HB_ITEM of 
'UNICODE' type.
3. It can be used by app as a usuall string including expression 
evaluation and passing to all string functions such as STR(), SUBSTR() ...
4. It can be output via GT as a UNICODE string
5. Items of 'UNICODE' type can be written to database unig PutValue method

I know it sounds like a lot of work. So my question was if there are 
some plans to make a _proper_ UNICODE implementation in xHarbour.

Regards,
Jacek

Miguel Angel Marchuet pisze:

> Really no change is necessary at xharbour, to finish your aplication.
>
> GetValue and PutValue don't knows the content of char * saved at database
> this is not important.
>
> For example we save utf8 strings in a standard dbf, obviously we need to
> overload comparation method to sort properly, but you don't have this problem.
>
> If you use windows aplication don't need to convert unicode to PLWIN, you 
> only need
> to convert to wide to paint chars correctly.
>
> for example
>
> HB_EXPORT LPWSTR hb_oleUTF8ToWide( LPSTR cString )
> {
>     if( cString )
>     {
>        DWORD length;
>        wchar_t * wString;
>
>        length = MultiByteToWideChar( CP_UTF8, 0, cString, -1, NULL, 0 );
>        wString = ( wchar_t * ) hb_xgrab( ( length + 1 ) * sizeof( wchar_t ) );
>        if( MultiByteToWideChar( CP_UTF8, 0, cString, -1, wString, length + 1 
> ) )
>           return (LPWSTR) wString;
>        else
>           hb_xfree( wString );
>     }
>
>     return NULL;
> }
>
> HB_FUNC( UTF8TOWIDE )  // ( cAnsiStr ) -> cWideStr
> {
>     char *cString = hb_parc( 1 );
>
>     if( cString )
>     {
>        BSTR wString = hb_oleUTF8ToWide( cString );
>
>        if( wString )
>        {
>           hb_retclenAdopt( (char *) wString, SysStringLen( wString ) );
>           return;
>        }
>     }
>
>     hb_ret();
>     return;
> }
>
>
>
> __________ Información de ESET NOD32 Antivirus, versión de la base de firmas 
> de virus 4489 (20091008) __________
>
> ESET NOD32 Antivirus ha comprobado este mensaje.
>
> http://www.eset.com
>
>
>
> ------------------------------------------------------------------------------
> Come build with us! The BlackBerry(R) Developer Conference in SF, CA
> is the only developer event you need to attend this year. Jumpstart your
> developing skills, take BlackBerry mobile applications to market and stay 
> ahead of the curve. Join us from November 9 - 12, 2009. Register now!
> http://p.sf.net/sfu/devconference
> _______________________________________________
> xHarbour-developers mailing list
> xHarbour-developers@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/xharbour-developers
>
>   


------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
xHarbour-developers mailing list
xHarbour-developers@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/xharbour-developers

Reply via email to