PC SOFT

FORUMS PROFESSIONNELS
WINDEVWEBDEV et WINDEV Mobile

Accueil → WINDEV Mobile 2024 → Solution to XML Reurn Chines em HttpRequest e HttpGetResult
Solution to XML Reurn Chines em HttpRequest e HttpGetResult
Débuté par adrianoboller, 18 nov. 2014 18:56 - 16 réponses
Membre enregistré
3 657 messages
Popularité : +175 (223 votes)
Posté le 18 novembre 2014 - 18:56
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
>
Membre enregistré
3 657 messages
Popularité : +175 (223 votes)
Posté le 18 novembre 2014 - 18:57
ProcedureWS_Android_iOs_ReadXml(XML_Retorno isstring,Xml_Atributo isstring)

//Exemplo de Uso:
// XML_Retorno is string = [
//<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
//xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
//xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/">
//<SOAP-ENV:Body SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
//xmlns:NS1="urn:act297_RtPlusSSDM-IRtPlusSSDM">
//<NS1:VerificarVersaoDeTabelasResponse xmlns:NS2="urn:act297_RtPlusSSDM">
//<NS2:TVersaoTabelas id="1" xsi:type="NS2:TVersaoTabelas">
//<datHoraMotivos xsi:type="xsd:string">2013-07-11T17:15:33</datHoraMotivos>
//<qtdMotivos xsi:type="xsd:int">3</qtdMotivos>
//<datHoraCartoes xsi:type="xsd:string">2013-07-01T12:00:00</datHoraCartoes>
//<qtdCartoes xsi:type="xsd:int">6</qtdCartoes>
//<datHoraPesquisa xsi:type="xsd:string">2013-07-10T12:14:42</datHoraPesquisa>
//<qtdPesquisa xsi:type="xsd:int">4</qtdPesquisa>
//</NS2:TVersaoTabelas>
//<return href="#1"/>
//</NS1:VerificarVersaoDeTabelasResponse>
//</SOAP-ENV:Body>
//</SOAP-ENV:Envelope>
// ]
//
// Uso da Funcao:
//arrTemp is array of strings = WS_Android_iOs_ReadXml(XML_Retorno,"NS2:TVersaoTabelas")

arrXml_TagResult isarray of strings
xposicaoinicial isint=0
Xposicaofinal isint=0
X isint=0
arrXml_Tag isarray of strings

Inicial isint=PositionOccurrence(XML_Retorno,"<"+Xml_Atributo,firstRank,FromBeginning)
Final isint=PositionOccurrence(XML_Retorno,"</"+Xml_Atributo+">",lastRank,FromEnd) +Length("</"+Xml_Atributo+">")
XML_Retorno=Middle(XML_Retorno,Inicial,Final-Inicial)
XML_Retorno=Replace(XML_Retorno,Xml_Atributo,"NoXml")
XML_Retorno="<Xml><Recorte>"+XML_Retorno+"</Recorte></Xml>"

nTotalxml isint=Length(XML_Retorno)

LOOP(nTotalxml)

X++
IFxposicaoinicial=0ANDXposicaofinal=0ANDXML_Retorno[[X]] ="<"THEN
X++
IFXML_Retorno[[X]] ="/"THEN
xposicaoinicial=X+1
END
END
IFxposicaoinicial>0ANDXML_Retorno[[X]] =">"THEN
Xposicaofinal=X
END
IFXposicaofinal>0ANDxposicaoinicial>0THEN
stag isstring=Middle(XML_Retorno,xposicaoinicial,Xposicaofinal-xposicaoinicial)
IFstag="NoXml"THEN
BREAK
END
Add(arrXml_Tag,stag)
Xposicaofinal=0
xposicaoinicial=0
END

END

//iOS - Apple (iPhone / iPad / iPod)
IFIniOSMode() =TrueTHEN

NoXml isstring
i isint=1
NoXml=XMLExtractString(XML_Retorno,"NoXml",i)

FOR EACH stag OFarrXml_Tag

temp isstring=XMLExtractString(NoXml,stag)
Add(arrXml_TagResult,temp)

END

//Android
ELSE IFInAndroidMode() =True

XmlDoc isXMLDocument
XmlDoc=XMLOpen(XML_Retorno,fromString)
NoXml isxmlNode

FOR EACH NoXml OF XmlDoc.Xml.Recorte on NoXml

FOR EACHsTag OFarrXml_Tag

Add(arrXml_TagResult,NoXml..ChildNode[sTag])

END

END

END

RESULTarrXml_TagResult
>
Membre enregistré
3 657 messages
Popularité : +175 (223 votes)
Posté le 18 novembre 2014 - 18:58
ok=HTTPRequest("http://"+IpSaladaFruta01+"/soap/IRtPlusSSDM","","",Xml_SEND,"text/xml","","")

IFok=True

//HTTPGetResult

XML_Retorno=WS_Android_IOS_HTTPGetResult()

XML_Retorno=Capitalize(WS_RemoveAcentos(XML_Retorno))

IFDebugSN="S"THEN
Info("/mnt/sdcard/TaxiFv/Arquivos/RetornoPosicaoTaxi.TXT",XML_Retorno)
IFInAndroidMode() =True
IFInSimulatorMode() =False
fSaveBuffer("/mnt/sdcard/TaxiFv/Arquivos/RetornoPosicaoTaxi.TXT",XML_Retorno)
ELSE
fSaveBuffer("c:\RetornoPosicaoTaxi.TXT",XML_Retorno)
END
END
END
END
>
Membre enregistré
3 657 messages
Popularité : +175 (223 votes)
Posté le 18 novembre 2014 - 19:13
Ansi x Unicode
Membre enregistré
3 657 messages
Popularité : +175 (223 votes)
Posté le 18 novembre 2014 - 19:37


>
Membre enregistré
3 657 messages
Popularité : +175 (223 votes)
Posté le 18 novembre 2014 - 19:40
OBS.:

>The Android and iOS project while using this configuration is that the global definition of the project and the button: "Describing the current configuration" which is at the bottom of the screen.
Membre enregistré
3 657 messages
Popularité : +175 (223 votes)
Posté le 18 novembre 2014 - 20:14
"Describing the current configuration"
Membre enregistré
3 657 messages
Popularité : +175 (223 votes)
Posté le 05 décembre 2014 - 08:48
Adriano
On pagehttp://forum.pcsoft.fr/fr-FR/pcsoft.fr.windevmobile/18410-qui-maitrise-utf8-ansi-unicode/read.awp

it is written:
4) I integrate the text file into my table by reading fOpen()

and this is what was the problem for me for my text file geonames
I try UTF8ToString() AnsiVersUnicode() and UnicodeToAnsi() without result

>A you try with a text file containing Greek characters, Chinese, Japanese, Hebrew or Latin characters not?
Membre enregistré
3 657 messages
Popularité : +175 (223 votes)
Posté le 09 décembre 2014 - 17:56
IFStringCount(bufResHTTP, “ISO-8859-1,IgnoreCase) =0THEN
sHTTPResult=UTF8ToString(bufResHTTP)
ELSE
sHTTPResult=AnsiToUnicode(bufResHTTP)
END
>
Membre enregistré
3 657 messages
Popularité : +175 (223 votes)
Posté le 09 décembre 2014 - 18:01
I work only with Latin characters without Chinese characters or umlauts.

Use this function here:

Return_Json = NoAccent(Return_Json)

And

http://forum.pcsoft.fr/fr-FR/pcsoft.us.windevmobile/959-remove-acento-961/read.awp>
Membre enregistré
3 657 messages
Popularité : +175 (223 votes)
Posté le 29 janvier 2015 - 12:52
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
>
Membre enregistré
3 657 messages
Popularité : +175 (223 votes)
Membre enregistré
3 657 messages
Popularité : +175 (223 votes)
Posté le 25 mai 2015 - 21:09
:merci:>
Membre enregistré
3 657 messages
Popularité : +175 (223 votes)
Posté le 26 mai 2015 - 19:19
/////// para ler o arquivo em Unicode gerado por um app feito em Windev Mobile para Android ou iOS

MyUnicodeString is UNICODEstring
sLine isstring=""
sTextFileUnicode isstring="c:\tmp\00010101.txt"// formato Unicode
mLinha isstring

// aqui coloquei o parametro "foAnsi"

MyUnicodeString=fLoadText(sTextFileUnicode,foAnsi)// carregar o texto

// aqui coloquei o parametro "charsetAnsi"

sLine=UnicodeToAnsi(MyUnicodeString,charsetAnsi)// converter o texto

ListDeleteAll(ListBox1)
ListAdd(ListBox1,sLine)// jogar o texto convertido em um ListBox

FOR EACH ROW OF ListBox1// ler linha a linha e tratá-la de acordo com as suas regras
mLinha=ListBox1..DisplayedValue// receber o conteudo de cada linha do texto
Trace(mLinha)// visualizar o conteudo lido em mLinha para efeito didático apenas
END

////////////////// FIM //////////////////

// para gravar o arquivo em unicode por um app iOS/Android feito em Windev Mobile

xFLagOk isboolean
FileID isint=fCreate(DirPadrao+mArquivo,foAnsi)// aqui coloquei o parametro "foAnsi"
IFFileID=-1THEN
Info("Erro ao criar arquivo.")
xFlagOk=False
RETURN
END

...// ponha o seu codigo aqui
...// ponha o seu código aqui

// aqui coloquei o parâmetro ftpASCIIMode

EnviarArquivo isboolean=FTPSend(MinhaConexao,DirPadrao+mArquivo,CompleteDir(xPastaPedidos),"",ftpASCIIMode)
IFEnviarArquivo=FalseTHEN
Error("Erro ao enviar arquivo para o FTP.",ErrorInfo())
Info("Arquivo não foi enviado.","Tente enviá-lo novamente.")
xFlagOk=False
RETURN
END
>
Membre enregistré
3 657 messages
Popularité : +175 (223 votes)
Posté le 26 mai 2015 - 19:20
Membre enregistré
3 657 messages
Popularité : +175 (223 votes)
Posté le 19 septembre 2015 - 21:25
OBS. : E se ainda tiver problemas use antes de qualquer codigo esse comando:

ChangeCharset(charsetOccidental)// SEM ACENTO


--
Adriano Jose Boller
______________________________________________
Consultor e Representante Oficial da
PcSoft no Brasil
+55 (41) 9949 1800
adrianoboller@gmail.com
>______________________________________________