Re: tdom encoding

Liste des GroupesRevenir à cl tcl 
Sujet : Re: tdom encoding
De : gregor.ebbing (at) *nospam* gmx.de (greg)
Groupes : comp.lang.tcl
Date : 17. Dec 2024, 03:13:14
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <vjqmnq$1dblc$1@dont-email.me>
References : 1
User-Agent : Mozilla Thunderbird
Am 17.12.24 um 01:01 schrieb saito:
I am trying to see why tdom is failing on this json snippet.
 package req tdom
set x {{"name":"Jeremi"}}
dom parse -json $x
 ==> error "JSON syntax error" at position 15
"{"name":"Jeremi <--Error-- "}"
  If it doesn't get removed by the newsgroup editors, there is a weird character at the very end of x.  It looks almost like "[]" but it is not.  When you edit it, it acts as if it has multiple characters in it.
  Another problem is that tdom man page talks about a command "dom setResultEncoding ?encodingName?" but trying it results in an unknown command error.
 
Hello,
The unknown character is 007 or BELL.
Probably not allowed as a char in  string.
Instead: \u0007
Gregor
package req tdom
proc chr c {
   if {[string length $c] > 1 } {
     error "chr: arg should be a single char"
   }
   set v 0
   scan $c %c v
   return $v
}
# Check character types and provide additional information
proc charInfo char {
   if {[string is control $char]} {
     return "control character"
   } elseif {[string is space $char]} {
     return "space character"
   } elseif {[string is digit $char]} {
     return "digit character"
   } elseif {[string is lower $char]} {
     return "lowercase alphabetic character"
   } elseif {[string is upper $char]} {
     return "uppercase alphabetic character"
   } elseif {[string is punct $char]} {
     return "punctuation character"
   } elseif {[string is graph $char]} {
     return "graphical character"
   } elseif {[string is print $char]} {
     return "printable character"
   } else {
     return "unknown character type"
   }
}
proc infochar {x} {
   puts $x
   set i 0
   while {$i<[string length $x]} {
     set c [string index $x $i]
     puts "$i is $c [charInfo $c] [chr $c] "
     incr i
   }
}
set x {{"name":"Jeremi"}}
infochar $x
catch {dom parse -json $x} mess
puts "mess: $mess"
set x {{"name":"Jeremi\u0007"}}
set doc [dom parse -json $x]
puts [$doc asXML]

Date Sujet#  Auteur
17 Dec 24 * tdom encoding10saito
17 Dec 24 +* Re: tdom encoding4greg
17 Dec 24 i+* Re: tdom encoding2saito
17 Dec 24 ii`- Re: tdom encoding1Rich
19 Dec 24 i`- Re: tdom encoding1Alan Grunwald
17 Dec 24 +- Re: tdom encoding1Rich
18 Dec 24 `* Re: tdom encoding4Rolf Ade
18 Dec 24  `* Re: tdom encoding3saito
18 Dec 24   `* Re: tdom encoding2Harald Oehlmann
18 Dec 24    `- Re: tdom encoding1saito

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal