FORUMS PROFESSIONNELS
WINDEV
,
WEBDEV
et
WINDEV Mobile
Accueil
|
Messages récents
|
Connexion
|
Déconnexion
|
Français
Accueil
→
WINDEV Mobile 2024
→
Json To Ansi
Json To Ansi
Débuté par adrianoboller, 18 nov. 2014 13:44 - Aucune réponse
Connectez-vous…
adrianoboller
#1
Membre enregistré
3 661 messages
Popularité : +175 (223 votes)
Posté le 18 novembre 2014 - 13:44
// Life Tech 29/10/2014
// Summary: converte a sequencia Escape '\' usada em Json para Ansi
// Syntax:
//[ <Result> = ] JsonToAnsi (<TextoJson>)
//
// Parameters:
//
TextoJson: texto Json
// Return Value:
//
UNICODE string:
// texto Ansi
Procedure
JsonToAnsi
(
TextoJson
)
res is
string
iniciouString is
boolean
i is
int
=
1
LOOP
IF
i
>
Length
(
TextoJson
)
THEN BREAK
IF
TextoJson
[
[i]
]
=
""
""
THEN
iniciouString
=
1
-
iniciouString
;
res
+
=
""
""
;
i
+
+
ELSE
IF
iniciouString
THEN
// dentro do "string"
IF
TextoJson
[
[i]
]
=
"\"
AND
i
<
Length
(
TextoJson
)
THEN
// dentro da sequencia Escape "\"
SWITCH
TextoJson
[
[i+
1
]
]
CASE
""
""
:
res
+
=
""
""
;
i
+
=
2
// quotation mark
CASE
"\"
:
res
+
=
"\"
;
i
+
=
2
// reverse solidus
CASE
"/"
:
res
+
=
"/"
;
i
+
=
2
// solidus
CASE
"b"
:
res
+
=
"<"
;
i
+
=
2
// backspace
CASE
"f"
:
res
+
=
CR
+
CR
;
i
+
=
2
// formfeed
CASE
"n"
:
res
+
=
CR
;
i
+
=
2
// new line
CASE
"r"
:
res
+
=
CR
;
i
+
=
2
// carriage return
CASE
"t"
:
res
+
=
TAB
;
i
+
=
2
// horizontal Tab
CASE
"u"
:
// hexadecimal digits \u1234
IF
i
+
5
<
=
Length
(
TextoJson
)
THEN
res
+
=
Charact
(
HexaToInt
(
TextoJson
[
[i+
2
TO i
+
5
]
]
)
)
i
+
=
6
END
OTHER
CASE
res
+
=
TextoJson
[
[i]
]
;
i
+
+
END
ELSE
// fora da sequencia Escape "\"
res
+
=
TextoJson
[
[i]
]
;
i
+
+
END
ELSE
// fora do "string"
res
+
=
TextoJson
[
[i]
]
;
i
+
+
END
END
END
RESULT
res
Signaler
0
0
→ Revenir à WINDEV Mobile 2024
WINDEV 2024
WEBDEV 2024
WINDEV Mobile 2024
WINDEV (précédentes versions)
Français
English
Español
Portuguesa
Fermer cette fenêtre
Type de recherche
Uniquement les sujets
Tous les messages
Période de recherche
Date indifférente
Moins d'une heure
Moins de 24 heures
Moins d'une semaine
Moins d'un mois
Moins d'un an
Annuler
Aperçu de votre message
Ajouter une image
Importer une image depuis une URL
Envoyer une image depuis un fichier de votre disque
Déposez ici un fichier ou cliquez sur "Parcourir..."
ou
Annuler
0%
WLangage
SQL
XML, HTML
JAVA, Javascript
Texte