Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
simplejson
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
OpenVMS
Python
Modules
simplejson
Commits
ff9bc79f8313
Commit
ff9bc79f8313
authored
17 years ago
by
Bob Ippolito
Browse files
Options
Downloads
Patches
Plain Diff
http://code.google.com/p/simplejson/issues/detail?id=10
git-svn-id:
http://simplejson.googlecode.com/svn/trunk@86
a4795897-2c25-0410-b006-0d3caba88fa1
parent
f11a669bab5e
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
simplejson/encoder.py
+6
-3
6 additions, 3 deletions
simplejson/encoder.py
simplejson/tests/test_unicode.py
+22
-2
22 additions, 2 deletions
simplejson/tests/test_unicode.py
with
28 additions
and
5 deletions
simplejson/encoder.py
+
6
−
3
View file @
ff9bc79f
...
...
@@ -350,4 +350,5 @@
if
(
_encoding
is
not
None
and
not
(
_encoding
==
'
utf-8
'
and
_need_utf8
)):
o
=
o
.
decode
(
_encoding
)
if
self
.
ensure_ascii
:
return
encode_basestring_ascii
(
o
)
...
...
@@ -353,4 +354,6 @@
return
encode_basestring_ascii
(
o
)
else
:
return
encode_basestring
(
o
)
# This doesn't pass the iterator directly to ''.join() because it
# sucks at reporting exceptions. It's going to do this internally
# anyway because it uses PySequence_Fast or similar.
...
...
This diff is collapsed.
Click to expand it.
simplejson/tests/test_unicode.py
+
22
−
2
View file @
ff9bc79f
...
...
@@ -18,6 +18,26 @@
js
=
S
.
dumps
(
s
,
encoding
=
'
utf-8
'
)
self
.
assertEquals
(
ju
,
js
)
def
test_encoding3
(
self
):
u
=
u
'
\N{GREEK SMALL LETTER ALPHA}\N{GREEK CAPITAL LETTER OMEGA}
'
j
=
S
.
dumps
(
u
)
self
.
assertEquals
(
j
,
'"
\\
u03b1
\\
u03a9
"'
)
def
test_encoding4
(
self
):
u
=
u
'
\N{GREEK SMALL LETTER ALPHA}\N{GREEK CAPITAL LETTER OMEGA}
'
j
=
S
.
dumps
([
u
])
self
.
assertEquals
(
j
,
'
[
"
\\
u03b1
\\
u03a9
"
]
'
)
def
test_encoding5
(
self
):
u
=
u
'
\N{GREEK SMALL LETTER ALPHA}\N{GREEK CAPITAL LETTER OMEGA}
'
j
=
S
.
dumps
(
u
,
ensure_ascii
=
False
)
self
.
assertEquals
(
j
,
u
'"
%s
"'
%
(
u
,))
def
test_encoding6
(
self
):
u
=
u
'
\N{GREEK SMALL LETTER ALPHA}\N{GREEK CAPITAL LETTER OMEGA}
'
j
=
S
.
dumps
([
u
],
ensure_ascii
=
False
)
self
.
assertEquals
(
j
,
u
'
[
"
%s
"
]
'
%
(
u
,))
def
test_big_unicode_encode
(
self
):
u
=
u
'
\U0001d120
'
self
.
assertEquals
(
S
.
dumps
(
u
),
'"
\\
ud834
\\
udd20
"'
)
...
...
@@ -21,7 +41,7 @@
def
test_big_unicode_encode
(
self
):
u
=
u
'
\U0001d120
'
self
.
assertEquals
(
S
.
dumps
(
u
),
'"
\\
ud834
\\
udd20
"'
)
self
.
assertEquals
(
S
.
dumps
(
u
,
ensure_ascii
=
False
),
'"
\
\
ud834
\\
udd
20
"'
)
self
.
assertEquals
(
S
.
dumps
(
u
,
ensure_ascii
=
False
),
u
'"
\
U0001d1
20
"'
)
def
test_big_unicode_decode
(
self
):
u
=
u
'
z
\U0001d120
x
'
...
...
@@ -32,4 +52,4 @@
for
i
in
range
(
0
,
0xd7ff
):
u
=
unichr
(
i
)
json
=
'"
\\
u%04x
"'
%
(
i
,)
self
.
assertEquals
(
S
.
loads
(
json
),
u
)
\ No newline at end of file
self
.
assertEquals
(
S
.
loads
(
json
),
u
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment