ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

This content has been translated automatically.  Click here  to view the French version.
Help / WLanguage / WLanguage functions / Standard functions / String functions
  • UTF-8 and ANSI conversion
  • Conversion in PHP
WINDEV
WindowsLinuxJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac Catalyst
Others
Stored procedures
Converts:
  • a character string in Unicode format into a character string in ANSI format (Windows).
  • a buffer containing a string in Unicode format into a buffer containing a string in ANSI (Windows) format.
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.
Example
MonBufferAnsi is Buffer
// Conversion du buffer MonBufferUnicode
// contenant une chaîne de caractères au format Unicode
// en un buffer contenant une chaîne de caractères au format ANSI
MonBufferAnsi = UnicodeToAnsi(MonBufferUnicode)
WINDEVWEBDEV - Server codeReports and QueriesAndroidAndroid Widget User code (UMC)PHPAjax
MaChaîneUnicode is string Unicode
MaChaîneAnsi is string
NumFic is int = fOuvre("c:\Temp\MonTexte.txt", foRead + foUnicode)
IF NumFic <> -1 THEN MaChaîneUnicode = fReadLine(NumFic)
MaChaîneAnsi = UnicodeToAnsi(MaChaîneUnicode, charsetGreek)
Syntax

Converting a Unicode string Hide the details

<Result> = UnicodeToAnsi(<String to convert> [, <Charset> [, <Unknown character>]])
<Result>: String or buffer
Character string in ANSI format.
<String to convert>: Unicode string
Unicode string to convert. This parameter can also be a string in ANSI format containing 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).
charsetCurrent
Default value
Uses the current character set specified with ChangeCharset (charsetOccidental by default).
charsetDefaultUses the computer's default character set. No character set is forced.
charsetEastEuropeEastern European characters (Polish, etc.).
charsetGreekGreek characters.
charsetHebrewHebrew characters.
charsetJapaneseJapanese characters.
charsetKoreanKorean characters.
charsetMacMac Roman character set (used in previous versions of Macintosh).
charsetOccidentalRoman characters in ANSI standard.
charsetRussianRussian characters.
charsetThaiThai characters;.
charsetTraditionalChineseTraditional Chinese characters (Republic of Taiwan).
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 a string of Unicode characters 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).
charsetCurrent
Default value
Current character set specified with ChangeCharset (charsetOccidental by default).
charsetDefaultUses the computer's default character set. No character set is forced.
charsetEastEuropeEastern European characters (Polish, etc.).
charsetGreekGreek characters.
charsetHebrewHebrew characters.
charsetJapaneseJapanese characters.
charsetKoreanKorean characters.
charsetMacMac Roman character set (used in previous versions of Macintosh).
charsetOccidentalRoman characters in ANSI standard.
charsetRussianRussian characters.
charsetThaiThai characters;.
charsetTraditionalChineseTraditional Chinese characters (Republic of Taiwan).
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
WINDEVWEBDEV - Server codeReports and QueriesAndroidAndroid Widget User code (UMC)PHPAjax

UTF-8 and ANSI conversion

To convert an ANSI string to UTF-8, use StringToUTF8.
To convert a UFT-8 string to ANSI, use:
PHP

Conversion in PHP

The conversion in PHP uses the following extensions:
  • the php_iconv.dll extension
  • the php_mbstring.dll extension
If none of these PHP extensions are used, only Latin characters will be converted (e.g., Chinese or Russian characters will not be converted).
The php_iconv.dll and php_mbstring.dll extensions are currently proposed on PHP servers. To find out if your host offers these extensions, simply enter the following information into a search engine: phpinfo <Host Name>.
To install these extensions on your own PHP server, simply uncomment the desired extension in the PHP.INI file.
Component: wd300vm.dll
Minimum version required
  • Version 9
This page is also available for…
Comments
PARA RESOLVER PROBLEMAS DE ACENTUAÇÃO
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


Procedure WS_Android_IOS_HTTPGetResult()

// Variable
bufResHTTP is Buffer
sHTTPResult is string

// Retrieves the result of the query

bufResHTTP=HTTPGetResult(httpResult)

// Result in UTF8 em iOS Apple

If IniOSMode() =True OR IniOSSimulatorMode() =True OR IniOSEmulatorMode() =True

IF StringCount(bufResHTTP, “ISO-8859-1”,IgnoreCase) =0

sHTTPResult=UTF8ToString(bufResHTTP)

ELSE

sHTTPResult=AnsiToUnicode(bufResHTTP)

END

ELSE IF inAndroidMode() =True OR InAndroidSimulatorMode() =True OR InAndroidEmulatorMode() =True

// Result in Android

sHTTPResult=bufResHTTP

END

RESULT sHTTPResult
adrianoboller
27 Mar. 2024

Last update: 09/18/2024

Send a report | Local help