Wednesday, June 21, 2017

Mac keyboard symbols in unicode

⌘ – ⌘ – ⌘ – the Command Key symbol
⌥ – ⌥ – ⌥ – the Option Key symbol
⇧ – ⇧ – ⇧ – the Shift Key symbol
⎋ – ⎋ – ⎋ – the ESC Key symbol
⇪ – ⇪ – ⇪ – the Capslock symbol
⏎ – ⏎ – ⏎ – the Return symbol
⌫ – ⌫ – ⌫ – the Delete / Backspace symbol

Tuesday, June 20, 2017

mojibake mongon

# -*- coding: utf-8 -*-

jstr = u"日本語"

print jstr.encode('iso-2022-jp')
print jstr.encode('euc-jp')
print jstr.encode('euc-jisx0213')
print jstr.encode('euc-jis-2004')
print jstr.encode('iso-2022-jp')
print jstr.encode('iso-2022-jp-1')
print jstr.encode('iso-2022-jp-2')
print jstr.encode('iso-2022-jp-3')
print jstr.encode('iso-2022-jp-ext')
print jstr.encode('iso-2022-jp-2004')

print jstr.encode('utf-7')
print jstr.encode('utf-8')
print jstr.encode('utf-16')
print jstr.encode('utf-16-be')
print jstr.encode('utf-16-le')

print jstr.encode('cp932')          #文字化けしない。
print jstr.encode('shift-jis')      #文字化けしない。
print jstr.encode('shift-jisx0213') #文字化けしない。
print jstr.encode('shift-jis-2004') #文字化けしない。

Tuesday, June 13, 2017

Japanese Characters & Strings in Python

hiragana
for i in range(0x3040, 0x30a0): print(chr(i), end='')
katakana
for i in range(0x30a0, 0x3100): print(chr(i), end='')
kanji
for i in range(0x4e00, 0x4f00): print(chr(i), end='')
morpho!

import sys
import codecs
sys.stdout = codecs.getwriter('utf8')(sys.stdout)
sys.stderr = codecs.getwriter('utf8')(sys.stderr)
export PYTHONIOENCODING=UTF-8

Monday, June 12, 2017

Japanese Character & String conversions in terminal

Unicode blocks for Japanese characters

  • 3000-303F is CJK Symbols and Punctuation.
  • 3040-309F is Hiragana.
  • 30A0-30FF is Katakana.
  • 4E00-9FFF is CJK Unified Ideographs.
  • FF00-FFEF is Half-width and Full-width Forms.
To convert between hiragana and katakana, shift code points by 0x60:
$ echo ひらがな|tr  $'[\u3040-\u309f]' $'[\u30a0-\u30ff]'
ヒラガナ
$ echo カタカナ|tr  $'[\u30a0-\u30ff]' $'[\u3040-\u309f]'
かたかな
To convert between full width and half width, use hyphen and tilde:
$ echo example|tr ' -~' $'\u3000\uff01-\uff5e'
example
$ echo example|tr $'\u3000\uff01-\uff5e' ' -~'
example

morpho!

Going one step further with Kotlin & gRPC

Recently, I tried using Quarkus with Kotlin for grpc. I have worked with grpc for communication between microservices in Java & Golang. ...