[PYTHON] [Tentative] How to convert a character string to Shift_jis with kivy-ios Memo kivy v1.8.0

If Kivy-ios is left as default, the multi-byte Japanese codec will not be installed. So change the settings and recompile.

Add the following description to Modules Setup under "kivy-ios / src / python_files /".

ModulesSetup


# for Japanese(Windows Charactor Code)
_codecs_jp cjkcodecs/_codecs_jp.c
_multibytecodec cjkcodecs/multibytecodec.c

This alone will not work with an error like "UnicodeDecodeError:'ascii' codec can't decode ....". As a result of various investigations, it seems that the default codec is ascii, so I will change the default of Python-2.7.1 to utf-8 (this will be fetched newly when compiling, so " Change gz2 in .cache "directly). Add the following files under "Lib".

sitecustomize.py


import sys
sys.setdefaultencoding("utf-8")

Now run "tools / build-all.sh" and you're ready to go.

sample



utf8data = '1234'
sjisdata = utf8data.encode('shift_jis')
print to_hex(sjisdata)

When executed, it will be converted correctly.

0x8250825182528253

[Caution] Apparently, it doesn't seem to be perfect yet, so the reverse conversion is not possible. I will update it as soon as I understand something.

Recommended Posts

[Tentative] How to convert a character string to Shift_jis with kivy-ios Memo kivy v1.8.0
How to convert / restore a string with [] in python
[Introduction to Python] How to split a character string with the split function
[Introduction to Python] How to write a character string with the format function
How to create a multi-platform app with kivy
How to convert a class object to a dictionary with SQLAlchemy
[Python] How to expand variables in a character string
I want to split a character string with hiragana
kivy-ios memo kivy v1.8.0 (MAC)
How to convert an array to a dictionary with Python [Application]
Python learning basics ~ How to output (display) a character string? ~
Convert a string to an image
Convert to a string while outputting standard output with Python subprocess
[Introduction to Python] How to output a character string in a Print statement
Try to extract a character string from an image with Python3
How to customize U-Boot with OSD335X on a custom board (memo)
How to extract the desired character string from a line 4 commands
How to call a POST request that supports Japanese (Shift-JIS) with requests
Convert memo at once with Python 2to3
kivy-ios memo kivy v1.8.0 URL linkage (MAC)
[Python] How to convert a 2D list to a 1D list
Convert character strings to features with RoBERTa
What do you like about how to convert an array (list) to a string?
How to read a CSV file with Python 2/3
How to send a message to LINE with curl
kivy-ios memo kivy v1.8.0 for new toolchain (MAC)
How to draw a 2-axis graph with pyplot
How to embed a variable in a python string
How to create a function object from a string
How to develop a cart app with Django
How to create a Kivy 1-line input box
I tried to generate a random character string
How to convert (32,32,3) to 4D tensor (1,32,32,1) with ndarray type
A memo on how to overcome the difficult problem of capturing FX with AI
A memo connected to HiveServer2 of EMR with python
How to delete the specified string with the sed command! !! !!
A memo of how to use AIST supercomputer ABCI
[Python] How to draw a line graph with Matplotlib
How to create a submenu with the [Blender] plugin
Convert a text file with hexadecimal values to a binary file
How to get a logged-in user with Django's forms.py
How to convert horizontally held data to vertically held data with pandas
How to make a shooting game with toio (Part 1)
How to convert JSON file to CSV file with Python Pandas
How to convert a mel spectrogram back to a wav file
[Python] A memo to write CSV vertically with Pandas
[Python] How to create a 2D histogram with Matplotlib
Upload to a shared drive with Google Drive API V3
[Python] How to draw a scatter plot with Matplotlib
How to operate Firefox with selenium on Windows Memo
How to quickly count the frequency of appearance of characters from a character string in Python?
Convert 202003 to 2020-03 with pandas
How to deploy a web app made with Flask to Heroku
How to make a Cisco Webex Teams BOT with Flask
How to put a hyperlink to "file: // hogehoge" with sphinx-> pdf
A memo on how to easily prepare a Linux exercise environment
How to install NPI + send a message to line with python
How to kill a process instantly with Python's Process Pool Executor
[Python] How to make a list of character strings character by character
How to output a document in pdf format with Sphinx
How to create a flow mesh around a cylinder with snappyHexMesh