Comments (8)
The fix seems in Python-2.6.2/Python/bltinmodule.c to change:
#if defined(MS_WINDOWS) && defined(HAVE_USABLE_WCHAR_T)
const char *Py_FileSystemDefaultEncoding = "mbcs";
#elif defined(__APPLE__)
const char *Py_FileSystemDefaultEncoding = "utf-8";
#else
const char *Py_FileSystemDefaultEncoding = NULL; /* use default */
#endif
To:
#if defined(MS_WINDOWS) && defined(HAVE_USABLE_WCHAR_T)
const char *Py_FileSystemDefaultEncoding = "mbcs";
#elif defined(__APPLE__)
const char *Py_FileSystemDefaultEncoding = "utf-8";
#else
const char *Py_FileSystemDefaultEncoding = "utf-8"; /* use default */
#endif
Source:
https://github.com/kivy/python-for-android/commit/c3b84199cdf7952d6b3cedb54130a1
988b099107
Original comment by [email protected]
on 30 Mar 2012 at 9:48
from python-for-android.
I try this patch and rebuid Python 2.6.2, not fixing.
Original comment by [email protected]
on 18 Apr 2012 at 2:57
from python-for-android.
Have you tried encoding/decoding paths in your own code, e.g.
some_string.encode('utf-8') ?
Please post some example code that shows the errors you are referring to.
Original comment by [email protected]
on 21 Apr 2012 at 3:06
from python-for-android.
Hello,
I'm having the same problem. With an application for parsing a xml, I got
UnicodeEncodeError when picking a non-ascii character.
print sys.getfilesystemencoding() gives me also "None" on SL4A, while on
Windows gives me "mbcs" (python 2.6 and 2.7) and Linux "UTF-8" (python 2.7).
I leave here an example (sorry if the code is not very clean, but I'm just
starting to work with python):
http://goo.gl/XWqfj
http://goo.gl/ylwtS
Both in Linux and Windows, works without problems. With SL4A and Python 2.6.2:
UnicodeEncodeError: 'ascii' codec can not encode character u '\ XE7' in
position 98: ordinal not in range (128)
I have also tried a few workarounds, such as distrito2.encode('utf8') or
repr(distrito2), but without success.
There is already a solution?
Thank you very much!
Best regards,
Pedro
Original comment by [email protected]
on 17 Aug 2012 at 11:29
from python-for-android.
Locale is broken so you would need to wrap with smth like:
_ENCODING = sys.getfilesystemencoding() or locale.getdefaultlocale()[1] or
'utf-8'
try:
my_stuff(string)
except (UnicodeEncodeError, UnicodeDecodeError):
my_stuff(string.encode(_ENCODING))
Original comment by [email protected]
on 17 Aug 2012 at 8:35
from python-for-android.
Hello Anthony,
It worked with _ENCODING = 'utf-8'
Thank you very much!
Best regards,
Pedro
Original comment by [email protected]
on 17 Aug 2012 at 11:35
from python-for-android.
>I try this patch and rebuid Python 2.6.2, not fixing.
I probably mistaked there as I rebuilt Python 2.7.2 with this patch and it
fixed.
You can build Python 2.7.2 with this patch (IPv6 patch too) there:
http://code.google.com/p/android-python27/source/browse/#hg%2Fpython-build ; or
you can use directly the already built version:
http://code.google.com/p/android-python27/source/browse/#hg%2Fapk%2Fres%2Fraw
And use it with SL4A, package.sh builds python_27.zip and python_extras_27.zip
(replacement for python_r16.zip and python_extras_r14.zip)
Original comment by [email protected]
on 18 Aug 2012 at 1:26
from python-for-android.
- python 2.7.9 => ok 'ascii'
- python 3.4.3 => ok 'utf-8'
from python-for-android.
Related Issues (20)
- Python 3.6.3 or 3.6.4 HOT 9
- readline not work with Python 3
- install binwalk HOT 4
- python not running in techo y6 HOT 2
- Large File Support for Python3
- SL4A crashed on XiaoMI3 and PythonForAndroid installation failed HOT 1
- Issue importing modules in Py4A HOT 1
- TypeError: makeFile() got an unexpected keyword argument 'encoding' HOT 7
- Json.decoder.JSONDecodeError:Expecting value: line 1 colum 1 (char 0) HOT 4
- how to find Python in adb shell ? HOT 2
- NoClassDefFoundError HOT 3
- Sl4A.apk not found in dir HOT 2
- `str(0.1)` aka float.__format__ outputs are different to another platform
- Problem with local install x86 HOT 1
- Android 9 support HOT 1
- No SSL Support included in this Python HOT 1
- How install SL4A on Termux? Is it possible? HOT 4
- release for aarch64 HOT 2
- please add build.gradle in root path HOT 2
- Fatal Python error HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from python-for-android.