PC SOFT

ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Home | Sign in | English EN
  • UTF-8 and ANSI conversion
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadApple WatchUniversal Windows 10 AppWindows Mobile
Others
Stored procedures
Converts:
  • a UNICODE string to an ANSI string (Windows).
  • a buffer containing a UNICODE string to a buffer containing an ANSI string (Windows).
Reminder:
  • ANSI is the character set used in Windows.
  • UNICODE is a character encoding standard. UNICODE is used to manage different languages and character sets.
Versions 16 and later
Java This function is now available for Java applications.
New in version 16
Java This function is now available for Java applications.
Java This function is now available for Java applications.
Versions 18 and later
Universal Windows 10 App This function is now available in Windows Store apps mode.
New in version 18
Universal Windows 10 App This function is now available in Windows Store apps mode.
Universal Windows 10 App This function is now available in Windows Store apps mode.
Versions 21 and later
Universal Windows 10 App This function is now available in Universal Windows 10 App mode.
New in version 21
Universal Windows 10 App This function is now available in Universal Windows 10 App mode.
Universal Windows 10 App This function is now available in Universal Windows 10 App mode.
Example
MyAnsiBuffer is Buffer
// Convert the MyUnicodeBuffer buffer
// that contains a UNICODE string
// to a buffer containing an ANSI string
MyAnsiBuffer = UnicodeToAnsi(MyUnicodeBuffer)
WINDEVUser code (UMC)
MyUnicodeString is UNICODE string
MyAnsiString is string
FileNum is int = fOpen("c:\Temp\MyText.txt", foRead + foUnicode)
IF FileNum <> -1 THEN MyUnicodeString = fReadLine(FileNum)
MyAnsiString = UnicodeToAnsi(MyUnicodeString, charsetGreek)
Syntax

Converting a Unicode string Hide the details

<Result> = UnicodeToAnsi(<String to convert> [, <Charset> [, <Unknown character>]])
<Result>: String or buffer
ANSI string.
<String to convert>: Unicode string
UNICODE string to be converted. This parameter can also be an ANSI string that contains UNICODE characters.
<Charset>: Optional Integer constant
Character set that will be used for the conversion.
charsetAnsiRoman characters in ANSI standard.
charsetArabicArabic characters.
charsetBalticBaltic characters.
charsetChineseChinese characters (People's Republic of China).
charsetTraditionalChineseTraditional Chinese characters (Republic of Taiwan).
charsetKoreanKorean characters.
charsetCurrent
Default value
Uses the current character set specified with ChangeCharset (charsetOccidental by default).
charsetDefault
Uses the computer's default character set. No character set is forced.
charsetEastEuropeEastern Europe characters (Polish, etc.).
charsetGreekGreek characters.
charsetHebrewHebrew characters.
charsetJapaneseJapanese characters.
Versions 20 and later
charsetMac
New in version 20
charsetMac
charsetMac
Mac Roman character set (used in previous versions of Macintosh).
charsetOccidentalRoman characters in ANSI standard.
charsetRussianRussian characters.
charsetThaiThai characters.
charsetTurkishTurkish characters.
charsetUTF8Used to manage UTF-8 (used in XML, for example).
charsetVietnameseVietnamese characters.
<Unknown character>: Optional character or constant
Character to use if an unknown character is encountered during the conversion process. The NULL constant allows you to use the default system character.

Converting a buffer containing a Unicode string Hide the details

<Result> = UnicodeToAnsi(<Buffer> [, <Charset> [, <Unknown character>]])
<Result>: Buffer
Buffer containing an ANSI string.
<Buffer>: Buffer
Buffer containing the UNICODE string to be converted. If <Buffer> contains an ANSI string, the result will be undefined.
<Charset>: Optional Integer constant
Character set that will be used for the conversion.
charsetAnsiRoman characters in ANSI standard.
charsetArabicArabic characters.
charsetBalticBaltic characters.
charsetChineseChinese characters (People's Republic of China).
charsetTraditionalChineseTraditional Chinese characters (Republic of Taiwan).
charsetKoreanKorean characters.
charsetCurrent
Default value
Current character set specified with ChangeCharset (charsetOccidental by default).
charsetDefault
Uses the computer's default character set. No character set is forced.
charsetEastEuropeEastern Europe characters (Polish, etc.).
charsetGreekGreek characters.
charsetHebrewHebrew characters.
charsetJapaneseJapanese characters.
Versions 20 and later
charsetMac
New in version 20
charsetMac
charsetMac
Mac Roman character set (used in previous versions of Macintosh).
charsetOccidentalRoman characters in ANSI standard.
charsetRussianRussian characters.
charsetThaiThai characters.
charsetTurkishTurkish characters.
charsetUTF8Used to manage UTF-8 (used in XML, for example).
charsetVietnameseVietnamese characters.
<Unknown character>: Optional character or constant
Character to use if an unknown character is encountered during the conversion process. The NULL constant allows you to use the default system character.
Remarks
WINDEVUniversal Windows 10 AppUser code (UMC)

UTF-8 and ANSI conversion

To convert an ANSI string to UTF-8, use StringToUTF8.
To convert a UFT-8 string to ANSI, use:
Component: wd260vm.dll
Minimum version required
  • Version 9
This page is also available for…
Comments
PARA RESOLVER PROBLEMAS DE ACENTUAÇÃO
Prezados,

Caso de problema com acentuação, use:

retorno is string = UFT8toString(textocomacento)

USE O COMANDO UTF8ToString OU AnsiToUnicode


ProcedureWS_Android_IOS_HTTPGetResult()

// Variable
bufResHTTP is Buffer
sHTTPResult isstring

// Retrieves the result of the query
bufResHTTP=HTTPGetResult(httpResult)

// Result in UTF8 em iOS Apple
IFIniOSMode() =TrueORIniOSSimulatorMode() =TrueORIniOSEmulatorMode() =True
IFStringCount(bufResHTTP, “ISO-8859-1”,IgnoreCase) =0THEN
sHTTPResult=UTF8ToString(bufResHTTP)
ELSE
sHTTPResult=AnsiToUnicode(bufResHTTP)
END
ELSE IFInAndroidMode() =TrueORInAndroidSimulatorMode() =TrueORInAndroidEmulatorMode() =True
// Result in Android
sHTTPResult=bufResHTTP
END

RESULTsHTTPResult
adrianoboller
24 Mar. 2016