memtimintursun / aspjson

Automatically exported from code.google.com/p/aspjson
0 stars 0 forks source link

Unicode characters are encoded with \uXXXX #2

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?

1. Create jsonObject with values including characters outside ASII range
such as Swedish 'å','ä','ö'

2. Flush the object to text 

Example:
dim o 
set o = new jsObject()
o("Name") = "åäö"
WScript.Stdout.Write o.Flush

What is the expected output? What do you see instead?
Expected result:
{"Name":"åäö"}
{"Name":"\u00E5\u00E4\u00F6"}

What version of the product are you using? On what operating system?
2.0.2

Please provide any additional information below.

I have patched the jsEncode function with these changes

'If a > 31  And a < 127 Then
'   jsEncode = jsEncode & c
'ElseIf a > -1  Or a < 65535 Then
'   jsEncode = jsEncode & "\u" & String(4 - Len(Hex(a)), "0") & Hex(a)
'End If 

If a > 31  Then
   jsEncode = jsEncode & c
ElseIf a > -1   Then
   jsEncode = jsEncode & "\u" & String(4 - Len(Hex(a)), "0") & Hex(a)
End If 

Original issue reported on code.google.com by Jonas.La...@gmail.com on 23 Jul 2008 at 10:58

GoogleCodeExporter commented 8 years ago
Error in the Example code. Should be
dim o 
set o = jsObject()
o("Name") = "åäö"
WScript.Stdout.Write o.Flush

Original comment by Jonas.La...@gmail.com on 23 Jul 2008 at 11:00

GoogleCodeExporter commented 8 years ago
Your example have a mistake. Flush method send to direct stdout.

There are correct samples
' 1. sample
Dim o
Set o = jsObject()
o("name") = "åäö"
o.Flush

' or
' 2. sample
Dim o
Set o = jsObject()
o("name") = "åäö"
WScript.StdOut.Write o.jsString

' or
' 3. sample
Dim o
Set o = jsObject()
o("name") = "åäö"
WScript.StdOut.Write toJSON(o)

åäö characters contains extended ascii. 2.0.2 have a defect. Thanks for

Original comment by tugrulto...@gmail.com on 24 Jul 2008 at 12:00

GoogleCodeExporter commented 8 years ago

Original comment by tugrulto...@gmail.com on 9 Nov 2009 at 11:05