unicode   24163

« earlier    

python - Can I redirect unicode output from the console directly into a file? - Stack Overflow
When printing to the console, Python looks at sys.stdout.encoding to determine the encoding to use to encode unicode objects before printing.

When redirecting output to a file, sys.stdout.encoding is None, so Python2 defaults to the ascii encoding. (In contrast, Python3 defaults to utf-8.) This often leads to an exception when printing unicode.

You can avoid the error by explicitly encoding the unicode yourself before printing:

print (unicode_obj.encode('utf-8'))

or you could redefine sys.stdout so all output is encoded in utf-8:

import sys
import codecs

- OR -

Set the environment variable PYTHONIOENCODING to the encoding you want before redirecting a python script to a file. Then you won't have to modify the original script. Make sure to write Unicode strings as well, otherwise PYTHONIOENCODING will have no effect. If you write byte strings, the bytes are sent as-is to the terminal (or redirected file).
python  redirect  sdtout  file  unicode  error  encoding 
2 days ago by christianmlong
Shapecatcher: Draw the Unicode character you want!
"This is a tool to help you find Unicode characters. Finding a specific character whose name you don't know is cumbersome. On shapecatcher.com, all you need to know is the shape of the character!"
unicode  characters  design 
7 days ago by teagueamania
What every JavaScript developer should know about Unicode
This is so very good. Just a really nice unicode walkthrough. This guy is a great teacher.
unicode  javascript  explain  goodstuff  html 
10 days ago by brentfarwick
HTML Unicode UTF-8 table of values and characters/images
A nice table with HTML names for special chars and images, as well as decimal and hexadecimal values. Shows how to display them in html.
unicode  table  characters  html  decimal  hexadecimal  goodstuff 
10 days ago by brentfarwick
Unicode HOWTO — Python 2.7.14 documentation
python docs howto for unicode

Search for the string 'encode'
unicode  python  encode  howto 
10 days ago by brentfarwick
Guide to the Unicode standard for regular folks
This helps you figure out how to find out what you need to know about unicode. It will help you if you need to dig into the standard, which can be quite confusing.
unicode  howto  goodstuff 
10 days ago by brentfarwick
Solving Unicode Problems in Python 2.7
One of the toughest things to get right in a Python program is Unicode handling. If you’re reading this, you’re probably in the middle of discovering this the hard way.
programming  unicode  python 
10 days ago by stuartcw

« earlier    

related tags

2017  ascii  basics  braille  character-sets  character  characters  charactersets  cli  code  compose  conference  database  decimal  design  development  dis  drawing  emoji  encode  encoding  error  explain  file  font-technology  fonts  frowning-poo  fun  fundamental  funny  generator  gis  github  goodstuff  graphics  hexadecimal  history  howto  html  i18n  image  info  inner  input  international  ios  iphone  issue  japanese  javascript  keyboard  knowhow  language  linux  mac  map  michael-everson  mysql  node.js  opensource  outlook  peril  perl  perlmod  pile-of-poo  poo  poop  prog  programming  python  python3  qa  rails  redirect  reference  regex  rendering  resources  sdtout  search  security  shape-recognition  shit  software  stories  string  strings  table  terminal  testing  text  tile  todo  tonews  tools  topology  typography  urxvt  utf8  vector  web  webdev  webutilities  work  working  xterm 

Copy this bookmark: