Hi people.
Do you know if the xBase or eXpress has any function for converting a string to utf-8?
Convert Ansi or OEM String to UTF-8
Convert Ansi or OEM String to UTF-8
Pedro Alexandre
Re: Convert Ansi or OEM String to UTF-8
Str2Unicode()
Converts an OEM/ANSI/ASCII character string to a Unicode string.
Str2Unicode( <cString> ) --> cuString
Parameters
<cString>
<cString> is an ANSI-encoded character string.
Return
The function returns a character string in Unicode format.
Description
Function Str2Unicode() converts an ANSI character string to Unicode format. The primary usage of Str2Unicode() is in conjunction with the native platform API.
Note: Str2Unicode() returns a string in UTF-16 Little Endian encoding, which is the native encoding used for Unicode character strings on the Windows platform.
See also
Unicode2Str()
IsUnicode()
File info
Static library
xppdui.lib
Dynamic library
xppdui.dll
Converts an OEM/ANSI/ASCII character string to a Unicode string.
Str2Unicode( <cString> ) --> cuString
Parameters
<cString>
<cString> is an ANSI-encoded character string.
Return
The function returns a character string in Unicode format.
Description
Function Str2Unicode() converts an ANSI character string to Unicode format. The primary usage of Str2Unicode() is in conjunction with the native platform API.
Note: Str2Unicode() returns a string in UTF-16 Little Endian encoding, which is the native encoding used for Unicode character strings on the Windows platform.
See also
Unicode2Str()
IsUnicode()
File info
Static library
xppdui.lib
Dynamic library
xppdui.dll
The eXpress train is coming - and it has more cars.
Re: Convert Ansi or OEM String to UTF-8
Pablos OT4XB (free) contains several functions to do this.
Best regards,
Tom
"Did I offend you?"
"No."
"Okay, give me a second chance."
Tom
"Did I offend you?"
"No."
"Okay, give me a second chance."
Re: Convert Ansi or OEM String to UTF-8
Yes, Pablos OT4XB conert easy, but use more and more memory after each call. I use instead functions from xb2net (Boris Borzic).
Piotr
Piotr
Re: Convert Ansi or OEM String to UTF-8
Hi people.
this function str2unicode() does not work.
It no return any Value.
maybe I´m not understaind the syntax usage or Perhaps I am not understanding how it is used.
If I do :
MyStringUTF := str2unicode('Pedro Alexandre Caliço Bagarrão')
the result returned to MyStringUTF is 'P'
The result does not make sense.
this function str2unicode() does not work.
It no return any Value.
maybe I´m not understaind the syntax usage or Perhaps I am not understanding how it is used.
If I do :
MyStringUTF := str2unicode('Pedro Alexandre Caliço Bagarrão')
the result returned to MyStringUTF is 'P'
The result does not make sense.
Pedro Alexandre
Re: Convert Ansi or OEM String to UTF-8
Look at the docs, Pedro: "Note: Str2Unicode returns a string in UTF-16 Little Endian encoding, which is the native encoding used for Unicode character strings on the Windows platform." And, above: "The primary use is in conjunction with the native platform API." Str2Unicode is used to send parameters to API calls. You can't display UTF-16 in your app. The return value is not a valid string for Xbase++ functions, since they expect 8-bit-OEM or ANSI.
Try the functions from Pablos OT4XB like "cAnsiToUtf8()" or "cOemToUtf8()" or those from Xb2.Net ("xbCPConvert()" and others).
What are you trying to do?
Try the functions from Pablos OT4XB like "cAnsiToUtf8()" or "cOemToUtf8()" or those from Xb2.Net ("xbCPConvert()" and others).
What are you trying to do?
Best regards,
Tom
"Did I offend you?"
"No."
"Okay, give me a second chance."
Tom
"Did I offend you?"
"No."
"Okay, give me a second chance."
Re: Convert Ansi or OEM String to UTF-8
Hi Tom.
I´m workinh on QRCode to print on billing documents.
to create the qrcode according to the specifications required by law it is necessary send the data in UTF-8 format.
The string to be sent can be about 500 characters.
I´m workinh on QRCode to print on billing documents.
to create the qrcode according to the specifications required by law it is necessary send the data in UTF-8 format.
The string to be sent can be about 500 characters.
Last edited by PedroAlex on Tue Oct 27, 2020 4:16 am, edited 1 time in total.
Pedro Alexandre
Re: Convert Ansi or OEM String to UTF-8
Hi, Pedro.
Try Pablos functions, they work well, and I can't confirm they're eating ressources. Just include ot4xb.ch in your source files, link ot4xb.lib to your app and deliver ot4xb.dll with it. https://blog.xbwin.com/
Try Pablos functions, they work well, and I can't confirm they're eating ressources. Just include ot4xb.ch in your source files, link ot4xb.lib to your app and deliver ot4xb.dll with it. https://blog.xbwin.com/
Best regards,
Tom
"Did I offend you?"
"No."
"Okay, give me a second chance."
Tom
"Did I offend you?"
"No."
"Okay, give me a second chance."
Re: Convert Ansi or OEM String to UTF-8
hi,
when have so many characters it is most "store" into JSON Format.
under harbour i use HMG Contribution to Print "any" Barcode / QRcode with HMG_Zebra
but it have a BUG in \Source\h_HMG_Zebra.Prg
https://www.hmgforum.com/viewtopic.php? ... 93&start=9
have a look here https://github.com/HMG-Official/HMG if it was fixed in latest HMG Contribution
Printing can be "external" ...
when have so many characters it is most "store" into JSON Format.
under harbour i use HMG Contribution to Print "any" Barcode / QRcode with HMG_Zebra
but it have a BUG in \Source\h_HMG_Zebra.Prg
https://www.hmgforum.com/viewtopic.php? ... 93&start=9
have a look here https://github.com/HMG-Official/HMG if it was fixed in latest HMG Contribution
greetings by OHR
Jimmy
Jimmy
Re: Convert Ansi or OEM String to UTF-8
Tom.
Jimmy.
Thank you for your help.
I think I already found the way.
StrokeScribe Activex Control can do both. Convert the string to utf and create the qrcode.
I'm doing tests and it seems to me that maybe it is the solution.
Jimmy.
Thank you for your help.
I think I already found the way.
StrokeScribe Activex Control can do both. Convert the string to utf and create the qrcode.
I'm doing tests and it seems to me that maybe it is the solution.
Pedro Alexandre