PC SOFT

FORUMS PROFESSIONNELS
WINDEVWEBDEV et WINDEV Mobile

Accueil → WINDEV Mobile 24 → ansi or unicode format
ansi or unicode format
Débuté par JOHNKEN, 20 nov. 2014 14:41 - 12 réponses
Membre enregistré
24 messages
Posté le 20 novembre 2014 - 14:41
How to detect if the text file you are accessing/opening is ansi or unicode format?
Posté le 20 novembre 2014 - 15:04
Hi

When you load it in a buffer variable, the first 2 bytes contains a
specific value in UNICODE mode. Be careful that there are several
variants of Unicode (little endian, big endian...), so there may be
several different header value to test.

You can of course check that out by using an Hexadecimal editor on your
files

Best regards

--
Fabrice Harari
International WinDev, WebDev and WinDev mobile Consulting

NEW: WXReplication, your open source replication system is available on
my web site!!!
WXShowroom.com: Show your projects!
More information on http://www.fabriceharari.com


On 11/20/2014 8:41 AM, JOHNKEN wrote:
How to detect if the text file you are accessing/opening is ansi or
unicode format?
Membre enregistré
2 958 messages
Popularité : +89 (91 votes)
Posté le 20 novembre 2014 - 15:20
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 THEN
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
Membre enregistré
2 958 messages
Popularité : +89 (91 votes)
Posté le 20 novembre 2014 - 15:28
JOHNKEN

I work with Windev Mobile set IN [x] ANSI GLOBAL project

I had to make this overall Procedure for making the identification was coming up the RETURN of the HTTPRequest with Unicode OR ANSI IN HTTPGetResult, I stopped using the standard command after the HTTPRequest AND I Use mine AND have had success.

Using my example Above Procedure:

url = "br.linkedin.com/in/adrianoboller"

ok is boolean = HTTPRequest (Url)

IF ok = True

RETURN is string = WS_Android_IOS_HTTPGetResult()

END

Came No more Japanese, Korean OR Chinese code AND thus... rssss.... :)
Membre enregistré
24 messages
Posté le 20 novembre 2014 - 16:08
Thanks for the reply guys...

another question, Im using windows ce device and want to read a text file copied to the device.
how will i determine automatically if that file is in ansi or unicode format.
Membre enregistré
2 958 messages
Popularité : +89 (91 votes)
Posté le 20 novembre 2014 - 21:39
Same Technique

IF StringCount(bufResHTTP, “ISO-8859-1, IgnoreCase) = 0 THEN
RESULT = UTF8ToString(TextBuffer)
ELSE
RESULT = AnsiToUnicode(TextBuffer)
END
Membre enregistré
2 958 messages
Popularité : +89 (91 votes)
Posté le 20 novembre 2014 - 21:40
Procedure LE_ASCII(LOCAL ArquivoTxt)

//Le arquivo texto

// Declare the variables
PathFile is string = ArquivoTxt
IdFile, ResCloseFile, FileID, NumeroLinha is int
Line is string

// Open the file
FileID = fOpen(PathFile,foReadWrite)
IF IdFile = -1 THEN
Error(ErrorInfo(errMessage))
ELSE

//Converte de Unicode para Ansi
Line = UnicodeToAnsi(fReadLine(FileID))

//Linha 1
NumeroLinha = 1
//Info("Linha:" + NumeroLinha, Line)

WHILE Line <> EOT AND Line <> ""

//Proxima linha
NumeroLinha += 1
Line = fReadLine(FileID)
//Info("Linha:" + NumeroLinha, Line)

END
IF Line = "" THEN Error(ErrorInfo(errMessage))
IF Line = EOT THEN Info("Final do Arquivo.")
ResCloseFile = fClose(IdFile)
IF ResCloseFile = -1 THEN
//Error(ErrorInfo(errMessage))
END

END
Membre enregistré
2 958 messages
Popularité : +89 (91 votes)
Posté le 20 novembre 2014 - 21:44
Change your project globally to ANSI

P (Big Yellow) -> popup Mouse Right -> Project Description -> Down Button: [ DESCRIBING THE CURRENT CONFIGURATION ] -> Guia Aba: UNICODE -> Check [x] ANSI -> OK -> OK

Re-test code... ok
Posté le 20 novembre 2014 - 21:54
Hi

in what exactly is that another question? This looks exactly like the
one I already answered to...

Best regards

--
Fabrice Harari
International WinDev, WebDev and WinDev mobile Consulting

NEW: WXReplication, your open source replication system is available on
my web site!!!
WXShowroom.com: Show your projects!
More information on http://www.fabriceharari.com


On 11/20/2014 10:08 AM, JOHNKEN wrote:
Thanks for the reply guys...
another question, Im using windows ce device and want to read a text
file copied to the device.
how will i determine automatically if that file is in ansi or unicode
format.
Membre enregistré
24 messages
Posté le 21 novembre 2014 - 05:31
thanks adrianoboller,
got it already
Membre enregistré
2 958 messages
Popularité : +89 (91 votes)
Posté le 21 novembre 2014 - 13:27
JOHNKEN

But he succeed?

If not send me a mini project to try to help you...

Att

Adriano
Membre enregistré
24 messages
Posté le 21 novembre 2014 - 15:25
Hi Adriano,

I did it but its separate process for ansi and unicode file.

here is my sample project
https://www.dropbox.com/s/obuuq0q4pu5oqlh/AnsiUnicode.rar…
Membre enregistré
2 958 messages
Popularité : +89 (91 votes)
Posté le 22 novembre 2014 - 12:50
Ok I will look today and give you a return
Max until Monday

:merci: