Android Question [SOLVED] Strange characters in job response

Emme Developer

Well-Known Member
Licensed User
Longtime User
Hi to all!
I am downloading a text from a json page, but i don't know why i get some strange characters instead the text. If i see the page in a browser i get the right answer. This is the code, i hope someone can help me.

B4X:
Dim Job As HttpJob
    Job.Initialize("",Me)
    Job.Download("http://rubenalamina.mx//division/weapon-mods.json"")
    wait for (Job) JobDone(j As HttpJob)
    Log (j.GetString)
    Log(j.GetString2("UTF-8"))

** Service (starter) Destroy (ignored)**
*** Service (starter) Create ***
Device locale: it
Found 780 strings.
loc it
Found 780 strings.
loc it
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
Consent state: PERSONALIZED
EU: true
** Activity (main) Pause, UserClosed = false **
sending message to waiting queue (consentstateavailable)
*** Service (httputils2service) Create ***
** Service (httputils2service) Start **
** Activity (popup) Create, isFirst = true **
** Activity (popup) Resume **
** Activity (main) Pause, UserClosed = false **
** Activity (popup) Pause, UserClosed = false **
running waiting messages (1)
** Activity (main) Resume **
��[��
��
�� �� �� �� ��{��
��
�� �� �� �� �� �� �� �� ��"��t��y��p��e��"��:�� �� ��"��w��e��a��p��o��n��-��m��o��d��"��,��
��
�� �� �� �� �� �� �� �� ��"��v��e��n��d��o��r��"��:�� �� ��"��D��Z�� ��E��a��s��t�� ��5��3��r��d��"��,��
��
�� �� �� �� �� �� �� �� ��"��n��a��m��e��"��:�� �� ��"��H��e��a��v��y�� ��M��a��g��a��z��i��n��e�� ��S��p��r��i��n��g��"��,��
��
�� �� �� �� �� �� �� �� ��"��p��r��i��c��e��"��:�� �� ��"��D��Z�� ��2��1��,��3��6��2��"��,��
��
�� �� �� �� �� �� �� �� ��"��a��t��t��r��i��b��u��t��e��s��"��:�� �� ��"��5��%�� ��R��e��l��o��a��d�� ��S��p��e��e��d��<��b��r��/��>��4��%�� ��C��r��i��t��i��c��a��l�� ��H��i��t�� ��D��a��m��a��g��e��<��b��r��/��>��1��0��.��8��%�� ��R��a��t��e�� ��o��f�� ��F��i��r��e�� ��"��,��
��
�� �� �� �� �� �� �� �� ��"��r��e��c��o��m��m��e��n��d��e��d��"��:�� �� ��"��N��o��"��
��
�� �� �� �� ��}��,��
��
�� �� �� �� ��{��
��
�� �� �� �� �� �� �� �� ��"��t��y��p��e��"��:�� �� ��"��w��e��a��p��o��n��-��m��o��d��"��,��
��
�� �� �� �� �� �� �� �� ��"��v��e��n��d��o��r��"��:�� �� ��"��D��Z�� ��E��a��s��t�� ��4��6��t��h��"��,��
��
�� �� �� �� �� �� �� �� ��"��n��a��m��e��"��:�� �� ��"��P��E��Q��-��1��5�� ��L��a��s��e��r�� ��-�� ��O��r��a��n��g��e��"��,��
��
�� �� �� �� �� �� �� �� ��"��p��r��i��c��e��"��:�� �� ��"��D��Z�� ��2��4��,��1��3��7��"��,��
��
�� �� �� �� �� �� �� �� ��"��a��t��t��r��i��b��u��t��e��s��"��:�� �� ��"��1��5��.��5��%�� ��A��c��c��u��r��a��c��y��<��b��r��/��>��4��%�� ��O��p��t��i��m��a��l�� ��R��a��n��g��e��<��b��r��/��>��2��.��5��%�� ��S��t��a��b��i��l��i��t��y�� ��"��,��
��
�� �� �� �� �� �� �� �� ��"��r��e��c��o��m��m��e��n��d��e��d��"��:�� �� ��"��N��o��"��
��
�� �� �� �� ��}��,��
��
�� �� �� �� ��{��
��
�� �� �� �� �� �� �� �� ��"��t��y��p��e��"��:�� �� ��"��w��e��a��p��o��n��-��m��o��d��"��,��
��
�� �� �� �� �� �� �� �� ��"��v��e��n��d��o��r��"��:�� �� ��"��D��Z�� ��E��a��s��t�� ��4��2��n��d��"��,��
��
�� �� �� �� �� �� �� �� ��"��n��a��m��e��"��:�� �� ��"��F��l��a��s��h�� ��H��i��d��e��r��"��,��
��
�� �� �� �� �� �� �� �� ��"��p��r��i��c��e��"��:�� �� ��"��D��Z�� ��2��4��,��1��3��7��"��,��
��
�� �� �� �� �� �� �� �� ��"��a��t��t��r��i��b��u��t��e��s��"��:�� �� ��"��1��6��.��5��%�� ��A��c��c��u��r��a��c��y��<��b��r��/��>��5��.��5��%�� ��H��e��a��d��s��h��o��t�� ��D��a��m��a��g��e��<��b��r��/��>��2��.��5��%�� ��S��t��a��b��i��l��i��t��y�� ��"��,��
��
�� �� �� �� �� �� �� �� ��"��r��e��c��o��m��m��e��n��d��e��d��"��:�� �� ��"��N��o��"��
��
�� �� �� �� ��}��,��
��
�� �� �� �� ��{��
��
�� �� �� �� �� �� �� �� ��"��t��y��p��e��"��:�� �� ��"��w��e��a��p��o��n��-��m��o��d��"��,��
��
�� �� �� �� �� �� �� �� ��"��v��e��n��d��o��r��"��:�� �� ��"��D��Z�� ��E��a��s��t�� ��4��0��t��h��"��,��
��
�� �� �� �� �� �� �� �� ��"��n��a��m��e��"��:�� �� ��"��Q��u��i��c��k�� ��R��e��l��e��a��s��e�� ��M��a��g��a��z��i��n��e��"��,��
��
�� �� �� �� �� �� �� �� ��"��p��r��i��c��e��"��:�� �� ��"��D��Z�� ��2��1��,��3��6��2��"��,��
��
�� �� �� �� �� �� �� �� ��"��a��t��t��r��i��b��u��t��e��s��"��:�� �� ��"��2��8��.��5��%�� ��R��e��l��o��a��d�� ��S��p��e��e��d��<��b��r��/��>��1��2��%�� ��M��a��g��a��z��i��n��e�� ��S��i��z��e��<��b��r��/��>��4��%�� ��C��r��i��t��i��c��a��l�� ��H��i��t�� ��D��a��m��a��g��e�� ��"��,��
��
�� �� �� �� �� �� �� �� ��"��r��e��c��o��m��m��e��n��d��e��d��"��:�� �� ��"��N��o��"��
��
�� �� �� �� ��}��,��
��
�� �� �� �� ��{��
��
�� �� �� �� �� �� �� �� ��"��t��y��p��e��"��:�� �� ��"��w��e��a��p��o��n��-��m��o��d��"��,��
��
�� �� �� �� �� �� �� �� ��"��v��e��n��d��o��r��"��:�� �� ��"��D��Z�� ��E��a��s��t�� ��3��4��t��h��"��,��
��
�� �� �� �� �� �� �� �� ��"��n��a��m��e��"��:�� �� ��"��C��o��m��p��e��n��s��a��t��o��r��"��,��
��
�� �� �� �� �� �� �� �� ��"��p��r��i��c��e��"��:�� �� ��"��D��Z�� ��2��4��,��1��3��7��"��,��
��
�� �� �� �� �� �� �� �� ��"��a��t��t��r��i��b��u��t��e��s��"��:�� �� ��"��1��3��%�� ��S��t��a��b��i��l��i��t��y��<��b��r��/��>��2��%�� ��A��c��c��u��r��a��c��y��<��b��r��/��>��2��.��5��%�� ��C��r��i��t��i��c��a��l�� ��H��i��t�� ��C��h��a��n��c��e�� ��"��,��
��
�� �� �� �� �� �� �� �� ��"��r��e��c��o��m��m��e��n��d��e��
Message longer than Log limit (4000). Message was truncated.
��[��
��
�� �� �� �� ��{��
��
�� �� �� �� �� �� �� �� ��"��t��y��p��e��"��:�� �� ��"��w��e��a��p��o��n��-��m��o��d��"��,��
��
�� �� �� �� �� �� �� �� ��"��v��e��n��d��o��r��"��:�� �� ��"��D��Z�� ��E��a��s��t�� ��5��3��r��d��"��,��
��
�� �� �� �� �� �� �� �� ��"��n��a��m��e��"��:�� �� ��"��H��e��a��v��y�� ��M��a��g��a��z��i��n��e�� ��S��p��r��i��n��g��"��,��
��
�� �� �� �� �� �� �� �� ��"��p��r��i��c��e��"��:�� �� ��"��D��Z�� ��2��1��,��3��6��2��"��,��
��
�� �� �� �� �� �� �� �� ��"��a��t��t��r��i��b��u��t��e��s��"��:�� �� ��"��5��%�� ��R��e��l��o��a��d�� ��S��p��e��e��d��<��b��r��/��>��4��%�� ��C��r��i��t��i��c��a��l�� ��H��i��t�� ��D��a��m��a��g��e��<��b��r��/��>��1��0��.��8��%�� ��R��a��t��e�� ��o��f�� ��F��i��r��e�� ��"��,��
��
�� �� �� �� �� �� �� �� ��"��r��e��c��o��m��m��e��n��d��e��d��"��:�� �� ��"��N��o��"��
��
�� �� �� �� ��}��,��
��
�� �� �� �� ��{��
��
�� �� �� �� �� �� �� �� ��"��t��y��p��e��"��:�� �� ��"��w��e��a��p��o��n��-��m��o��d��"��,��
��
�� �� �� �� �� �� �� �� ��"��v��e��n��d��o��r��"��:�� �� ��"��D��Z�� ��E��a��s��t�� ��4��6��t��h��"��,��
��
�� �� �� �� �� �� �� �� ��"��n��a��m��e��"��:�� �� ��"��P��E��Q��-��1��5�� ��L��a��s��e��r�� ��-�� ��O��r��a��n��g��e��"��,��
��
�� �� �� �� �� �� �� �� ��"��p��r��i��c��e��"��:�� �� ��"��D��Z�� ��2��4��,��1��3��7��"��,��
��
�� �� �� �� �� �� �� �� ��"��a��t��t��r��i��b��u��t��e��s��"��:�� �� ��"��1��5��.��5��%�� ��A��c��c��u��r��a��c��y��<��b��r��/��>��4��%�� ��O��p��t��i��m��a��l�� ��R��a��n��g��e��<��b��r��/��>��2��.��5��%�� ��S��t��a��b��i��l��i��t��y�� ��"��,��
��
�� �� �� �� �� �� �� �� ��"��r��e��c��o��m��m��e��n��d��e��d��"��:�� �� ��"��N��o��"��
��
�� �� �� �� ��}��,��
��
�� �� �� �� ��{��
��
�� �� �� �� �� �� �� �� ��"��t��y��p��e��"��:�� �� ��"��w��e��a��p��o��n��-��m��o��d��"��,��
��
�� �� �� �� �� �� �� �� ��"��v��e��n��d��o��r��"��:�� �� ��"��D��Z�� ��E��a��s��t�� ��4��2��n��d��"��,��
��
�� �� �� �� �� �� �� �� ��"��n��a��m��e��"��:�� �� ��"��F��l��a��s��h�� ��H��i��d��e��r��"��,��
��
�� �� �� �� �� �� �� �� ��"��p��r��i��c��e��"��:�� �� ��"��D��Z�� ��2��4��,��1��3��7��"��,��
��
�� �� �� �� �� �� �� �� ��"��a��t��t��r��i��b��u��t��e��s��"��:�� �� ��"��1��6��.��5��%�� ��A��c��c��u��r��a��c��y��<��b��r��/��>��5��.��5��%�� ��H��e��a��d��s��h��o��t�� ��D��a��m��a��g��e��<��b��r��/��>��2��.��5��%�� ��S��t��a��b��i��l��i��t��y�� ��"��,��
��
�� �� �� �� �� �� �� �� ��"��r��e��c��o��m��m��e��n��d��e��d��"��:�� �� ��"��N��o��"��
��
�� �� �� �� ��}��,��
��
�� �� �� �� ��{��
��
�� �� �� �� �� �� �� �� ��"��t��y��p��e��"��:�� �� ��"��w��e��a��p��o��n��-��m��o��d��"��,��
��
�� �� �� �� �� �� �� �� ��"��v��e��n��d��o��r��"��:�� �� ��"��D��Z�� ��E��a��s��t�� ��4��0��t��h��"��,��
��
�� �� �� �� �� �� �� �� ��"��n��a��m��e��"��:�� �� ��"��Q��u��i��c��k�� ��R��e��l��e��a��s��e�� ��M��a��g��a��z��i��n��e��"��,��
��
�� �� �� �� �� �� �� �� ��"��p��r��i��c��e��"��:�� �� ��"��D��Z�� ��2��1��,��3��6��2��"��,��
��
�� �� �� �� �� �� �� �� ��"��a��t��t��r��i��b��u��t��e��s��"��:�� �� ��"��2��8��.��5��%�� ��R��e��l��o��a��d�� ��S��p��e��e��d��<��b��r��/��>��1��2��%�� ��M��a��g��a��z��i��n��e�� ��S��i��z��e��<��b��r��/��>��4��%�� ��C��r��i��t��i��c��a��l�� ��H��i��t�� ��D��a��m��a��g��e�� ��"��,��
��
�� �� �� �� �� �� �� �� ��"��r��e��c��o��m��m��e��n��d��e��d��"��:�� �� ��"��N��o��"��
��
�� �� �� �� ��}��,��
��
�� �� �� �� ��{��
��
�� �� �� �� �� �� �� �� ��"��t��y��p��e��"��:�� �� ��"��w��e��a��p��o��n��-��m��o��d��"��,��
��
�� �� �� �� �� �� �� �� ��"��v��e��n��d��o��r��"��:�� �� ��"��D��Z�� ��E��a��s��t�� ��3��4��t��h��"��,��
��
�� �� �� �� �� �� �� �� ��"��n��a��m��e��"��:�� �� ��"��C��o��m��p��e��n��s��a��t��o��r��"��,��
��
�� �� �� �� �� �� �� �� ��"��p��r��i��c��e��"��:�� �� ��"��D��Z�� ��2��4��,��1��3��7��"��,��
��
�� �� �� �� �� �� �� �� ��"��a��t��t��r��i��b��u��t��e��s��"��:�� �� ��"��1��3��%�� ��S��t��a��b��i��l��i��t��y��<��b��r��/��>��2��%�� ��A��c��c��u��r��a��c��y��<��b��r��/��>��2��.��5��%�� ��C��r��i��t��i��c��a��l�� ��H��i��t�� ��C��h��a��n��c��e�� ��"��,��
��
�� �� �� �� �� �� �� �� ��"��r��e��c��o��m��m��e��n��d��e��
Message longer than Log limit (4000). Message was truncated.
** Activity (main) Pause, UserClosed = false **
 

Star-Dust

Expert
Licensed User
Longtime User
Are you sure the encoding is 'UTF-8'?
If you remove this character � that text comes out?

Give me this:
** Servizio (antipasto) Distruggi (ignorato) **
*** Servizio (iniziatore) Crea ***
Impostazioni locali del dispositivo: it
Trovato 780 corde.
loc it
Trovato 780 corde.
loc it
** Servizio (avviamento) Avvio **
** Attività (principale) Crea, isFirst = vero **
** Attività (principale) Riprendi **
Stato di consenso: PERSONALIZZATO
UE: vero
** Attività (principale) Pausa, UserClosed = falso **
invio messaggio alla coda di attesa (consenso disponibile)
*** Servizio (httputils2service) Crea ***
** Servizio (httputils2service) Avvia **
** Attività (popup) Crea, isFirst = true **
** Attività (popup) Riprendi **
** Attività (principale) Pausa, UserClosed = falso **
** Attività (popup) Pausa, UserClosed = falso **
running waiting messages (1)
** Attività (principale) Riprendi **
[

{

" t y p e " : " w e apon-mod",

" v e n d o r " : " D Z E a s t 5 3 r d " ,

" n a m e " : " H e a v y M a g a z i n e S p r i ng",

" p r i c e " : " D Z 2 1 , 3 6 2 " ,

" a t t r i b u t e s " : " 5 % R e l o a d S p e e d < b r / > 4 % C r i t i c a l H i t D a m a g e < b r / > 1 0 . 8 % R a t e o f F i r e " ,

" r e c o m m e n d e d " : " N o "

} ,

{

" t y p e " : " w e apon-mod",

" v e n d o r " : " D Z E a s t 4 6 t h " ,

" n a m e " : " P E Q - 1 5 L a s e r - O r a n ge",

" p r i c e " : " D Z 2 4 , 1 3 7 " ,

" a t t r i b u t e s " : " 1 5 . 5 % A c c u r a c y < b r / > 4 % O p t i m a l R a n g e < b r / > 2 . 5 % S t a b i l i t y " ,

" r e c o m m e n d e d " : " N o "

} ,

{

" t y p e " : " w e apon-mod",

" v e n d o r " : " D Z E a s t 4 2 n d " ,

" n a m e " : " F l a s h H i d e r " ,

" p r i c e " : " D Z 2 4 , 1 3 7 " ,

" a t t r i b u t e s " : " 1 6 . 5 % A c c u r a c y < b r / > 5 . 5 % H e a d s h o t D a m a g e < b r / > 2 . 5 % S t a b i l i t y " ,

" r e c o m m e n d e d " : " N o "

} ,

{

" t y p e " : " w e apon-mod",

" v e n d o r " : " D Z E a s t 4 0 t h " ,

" n a m e " : " Q u i c k R e l e a s e M a g a z ine",

" p r i c e " : " D Z 2 1 , 3 6 2 " ,

" a t t r i b u t e s " : " 2 8 . 5 % R e l o a d S p e e d < b r / > 1 2 % M a g a z i n e S i z e < b r / > 4 % C r i t i c a l H i t D a m a g e " ,

" r e c o m m e n d e d " : " N o "

} ,

{

" t y p e " : " w e apon-mod",

" v e n d o r " : " D Z E a s t 3 4 t h " ,

" n a m e " : " C o mpensator",

" p r i c e " : " D Z 2 4 , 1 3 7 " ,

" a t t r i b u t e s " : " 1 3 % S t a b i l i t y < b r / > 2 % A c c u r a c y < b r / > 2 . 5 % C r i t i c a l H i t C h a n c e " ,

" r e c o m m e n d e
Messaggio più lungo del limite log (4000). Il messaggio è stato troncato.
[

{

" t y p e " : " w e apon-mod",

" v e n d o r " : " D Z E a s t 5 3 r d " ,

" n a m e " : " H e a v y M a g a z i n e S p r i ng",

" p r i c e " : " D Z 2 1 , 3 6 2 " ,

" a t t r i b u t e s " : " 5 % R e l o a d S p e e d < b r / > 4 % C r i t i c a l H i t D a m a g e < b r / > 1 0 . 8 % R a t e o f F i r e " ,

" r e c o m m e n d e d " : " N o "

} ,

{

" t y p e " : " w e apon-mod",

" v e n d o r " : " D Z E a s t 4 6 t h " ,

" n a m e " : " P E Q - 1 5 L a s e r - O r a n ge",

" p r i c e " : " D Z 2 4 , 1 3 7 " ,

" a t t r i b u t e s " : " 1 5 . 5 % A c c u r a c y < b r / > 4 % O p t i m a l R a n g e < b r / > 2 . 5 % S t a b i l i t y " ,

" r e c o m m e n d e d " : " N o "

} ,

{

" t y p e " : " w e apon-mod",

" v e n d o r " : " D Z E a s t 4 2 n d " ,

" n a m e " : " F l a s h H i d e r " ,

" p r i c e " : " D Z 2 4 , 1 3 7 " ,

" a t t r i b u t e s " : " 1 6 . 5 % A c c u r a c y < b r / > 5 . 5 % H e a d s h o t D a m a g e < b r / > 2 . 5 % S t a b i l i t y " ,

" r e c o m m e n d e d " : " N o "

} ,

{

" t y p e " : " w e apon-mod",

" v e n d o r " : " D Z E a s t 4 0 t h " ,

" n a m e " : " Q u i c k R e l e a s e M a g a z ine",

" p r i c e " : " D Z 2 1 , 3 6 2 " ,

" a t t r i b u t e s " : " 2 8 . 5 % R e l o a d S p e e d < b r / > 1 2 % M a g a z i n e S i z e < b r / > 4 % C r i t i c a l H i t D a m a g e " ,

" r e c o m m e n d e d " : " N o "

} ,

{

" t y p e " : " w e apon-mod",

" v e n d o r " : " D Z E a s t 3 4 t h " ,

" n a m e " : " C o mpensator",

" p r i c e " : " D Z 2 4 , 1 3 7 " ,

" a t t r i b u t e s " : " 1 3 % S t a b i l i t y < b r / > 2 % A c c u r a c y < b r / > 2 . 5 % C r i t i c a l H i t C h a n c e " ,

" r e c o m m e n d e
Messaggio più lungo del limite log (4000). Il messaggio è stato troncato.
** Attività (principale) Pausa, UserClosed = falso **
 
Last edited:
Upvote 0

udg

Expert
Licensed User
Longtime User
Hi MDev,
using Firefox 59.0.2 and URL "https://rubenalamina.mx//division/weapon-mods.json" I get an error:
SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data
On "dati non elaborati" tab you can read
B4X:
��[
... same data as SD showed
 
Upvote 0

npsonic

Active Member
Licensed User
Okay, tested few different ways and here's what I found. It surely doesn't show correctly in B4A log view. I can see json correctly with browser though.
Json is in correct form, but there is some problem with B4A log view. Don't know why it doesn't show the json, but it's still there. Check with ex. MsgBox

B4X:
Dim get As HttpJob
get.Initialize("Get",Me)
get.Download("http://rubenalamina.mx//division/weapon-mods.json")
Wait For (get) JobDone(Job As HttpJob)
Log(Job.GetString)
Msgbox(Job.GetString,"Message")

Could it be that the json is UTF-8-BOM encoded and characters beginning are creating problems?
 
Last edited:
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
I can see json correctly with browser though
Not for me.
This is the result in Firefox on my PC
tv_033.png
 
Upvote 0

npsonic

Active Member
Licensed User
Okay, I was wrong json is encoded with UCS-2 LE BOM and thats why most browsers and B4A doesn't recognize it.

And it's confirmed. Works with encoding UCS-2

B4X:
Dim get As HttpJob
get.Initialize("Get",Me)
get.Download("http://rubenalamina.mx//division/weapon-mods.json")
Wait For (get) JobDone(Job As HttpJob)
Log(Job.GetString2("UCS-2"))
 
Upvote 0

npsonic

Active Member
Licensed User
Upvote 0

npsonic

Active Member
Licensed User
I guess it's 1993 :)
Whole Unicode Consortium was created 1991, so UTF-8 as an part of unicode standard as we know it is definitely developed after 1991.
There were some standards, before Unicode Consortium developed by The International Organization for Standardization such as ISO 10646 which was crafted 1989 and published 1990.

UTF-8 works since 1883 :D
Also I'm not quite sure how this is related to problem in this thread as UTF-8 couldn't be used to decode json.
One would need to use UTF-16 or UCS-2
 
Upvote 0
Top