8000 support more encoding types · RubinOrlando/wp-api-python@04c403f · GitHub
[go: up one dir, main page]

Skip to content

Commit 04c403f

Browse files
author
derwentx
committed
support more encoding types
1 parent 29faf97 commit 04c403f
< 8000 /header>

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

wordpress/helpers.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
__title__ = "wordpress-requests"
88

99
import json
10+
import locale
11+
import os
1012
import posixpath
1113
import re
1214
import sys
@@ -65,15 +67,14 @@ def to_binary(cls, string, encoding='utf8', errors='backslashreplace'):
6567

6668
@classmethod
6769
def jsonencode(cls, data, **kwargs):
68-
# kwargs['cls'] = BytesJsonEncoder
69-
# if PY2:
70-
# kwargs['encoding'] = 'utf8'
7170
if PY2:
72-
for encoding in [
71+
for encoding in filter(None, {
7372
kwargs.get('encoding', 'utf8'),
7473
sys.getdefaultencoding(),
74+
sys.getfilesystemencoding(),
75+
locale.getpreferredencoding(),
7576
'utf8',
76-
]:
77+
}):
7778
try:
7879
kwargs['encoding'] = encoding
7980
return json.dumps(data, **kwargs)

0 commit comments

Comments
 (0)
0