Keyboard의 표시된 기호들을 Unicode에서는 어떻게 읽는가?

ASCII table에 printable characters(Space ~ Tilt)를 가지고 변환해 보았다.


기호들중에 우리가 보통 칭하는 이름과는 다른 것들이 있었다. 

예를 들면 ^(Caret) 와 같이 내가 알고 있는 것과 다른것도 있었고, `(Grave Accent)처럼 어떻게 읽는지 신경쓰지 않고 있었던 것도 있었다.

 

# / 47 0x2f SOLIDUS

# ^ 94 0x5e CIRCUMFLEX ACCENT

# | 124 0x7c VERTICAL LINE



#!/usr/bin/env python

# -*- encoding: utf-8 -*-


# how to read Printable characters in ASCII


import unicodedata



# printable charaters in ASCII

# 32~126

SPACE = ord(' ')

TILT = ord('~')

for c in range(TILT - SPACE + 1):

    s = chr(SPACE + c)

    u = unicode(s)

    text = unicodedata.name(u)

    print u.encode('utf8'), SPACE + c, hex(SPACE + c), text


#   32 0x20 SPACE

# ! 33 0x21 EXCLAMATION MARK

# " 34 0x22 QUOTATION MARK

# # 35 0x23 NUMBER SIGN

# $ 36 0x24 DOLLAR SIGN

# % 37 0x25 PERCENT SIGN

# & 38 0x26 AMPERSAND

# ' 39 0x27 APOSTROPHE

# ( 40 0x28 LEFT PARENTHESIS

# ) 41 0x29 RIGHT PARENTHESIS

# * 42 0x2a ASTERISK

# + 43 0x2b PLUS SIGN

# , 44 0x2c COMMA

# - 45 0x2d HYPHEN-MINUS

# . 46 0x2e FULL STOP

# / 47 0x2f SOLIDUS

# 0 48 0x30 DIGIT ZERO

# 1 49 0x31 DIGIT ONE

# 2 50 0x32 DIGIT TWO

# 3 51 0x33 DIGIT THREE

# 4 52 0x34 DIGIT FOUR

# 5 53 0x35 DIGIT FIVE

# 6 54 0x36 DIGIT SIX

# 7 55 0x37 DIGIT SEVEN

# 8 56 0x38 DIGIT EIGHT

# 9 57 0x39 DIGIT NINE

# : 58 0x3a COLON

# ; 59 0x3b SEMICOLON

# < 60 0x3c LESS-THAN SIGN

# = 61 0x3d EQUALS SIGN

# > 62 0x3e GREATER-THAN SIGN

# ? 63 0x3f QUESTION MARK

# @ 64 0x40 COMMERCIAL AT

# A 65 0x41 LATIN CAPITAL LETTER A

# B 66 0x42 LATIN CAPITAL LETTER B

# C 67 0x43 LATIN CAPITAL LETTER C

# D 68 0x44 LATIN CAPITAL LETTER D

# E 69 0x45 LATIN CAPITAL LETTER E

# F 70 0x46 LATIN CAPITAL LETTER F

# G 71 0x47 LATIN CAPITAL LETTER G

# H 72 0x48 LATIN CAPITAL LETTER H

# I 73 0x49 LATIN CAPITAL LETTER I

# J 74 0x4a LATIN CAPITAL LETTER J

# K 75 0x4b LATIN CAPITAL LETTER K

# L 76 0x4c LATIN CAPITAL LETTER L

# M 77 0x4d LATIN CAPITAL LETTER M

# N 78 0x4e LATIN CAPITAL LETTER N

# O 79 0x4f LATIN CAPITAL LETTER O

# P 80 0x50 LATIN CAPITAL LETTER P

# Q 81 0x51 LATIN CAPITAL LETTER Q

# R 82 0x52 LATIN CAPITAL LETTER R

# S 83 0x53 LATIN CAPITAL LETTER S

# T 84 0x54 LATIN CAPITAL LETTER T

# U 85 0x55 LATIN CAPITAL LETTER U

# V 86 0x56 LATIN CAPITAL LETTER V

# W 87 0x57 LATIN CAPITAL LETTER W

# X 88 0x58 LATIN CAPITAL LETTER X

# Y 89 0x59 LATIN CAPITAL LETTER Y

# Z 90 0x5a LATIN CAPITAL LETTER Z

# [ 91 0x5b LEFT SQUARE BRACKET

# \ 92 0x5c REVERSE SOLIDUS

# ] 93 0x5d RIGHT SQUARE BRACKET

# ^ 94 0x5e CIRCUMFLEX ACCENT

# _ 95 0x5f LOW LINE

# ` 96 0x60 GRAVE ACCENT

# a 97 0x61 LATIN SMALL LETTER A

# b 98 0x62 LATIN SMALL LETTER B

# c 99 0x63 LATIN SMALL LETTER C

# d 100 0x64 LATIN SMALL LETTER D

# e 101 0x65 LATIN SMALL LETTER E

# f 102 0x66 LATIN SMALL LETTER F

# g 103 0x67 LATIN SMALL LETTER G

# h 104 0x68 LATIN SMALL LETTER H

# i 105 0x69 LATIN SMALL LETTER I

# j 106 0x6a LATIN SMALL LETTER J

# k 107 0x6b LATIN SMALL LETTER K

# l 108 0x6c LATIN SMALL LETTER L

# m 109 0x6d LATIN SMALL LETTER M

# n 110 0x6e LATIN SMALL LETTER N

# o 111 0x6f LATIN SMALL LETTER O

# p 112 0x70 LATIN SMALL LETTER P

# q 113 0x71 LATIN SMALL LETTER Q

# r 114 0x72 LATIN SMALL LETTER R

# s 115 0x73 LATIN SMALL LETTER S

# t 116 0x74 LATIN SMALL LETTER T

# u 117 0x75 LATIN SMALL LETTER U

# v 118 0x76 LATIN SMALL LETTER V

# w 119 0x77 LATIN SMALL LETTER W

# x 120 0x78 LATIN SMALL LETTER X

# y 121 0x79 LATIN SMALL LETTER Y

# z 122 0x7a LATIN SMALL LETTER Z

# { 123 0x7b LEFT CURLY BRACKET

# | 124 0x7c VERTICAL LINE

# } 125 0x7d RIGHT CURLY BRACKET

# ~ 126 0x7e TILDE


EOF


#

Ghost.py 설치

http://jeanphix.me/Ghost.py/


$ sudo apt-get install qt-sdk python-pyside

$ sudo pip install pyside


$ git clone https://github.com/jeanphix/Ghost.py.git ghost

$ cd ghost

$ sudo python setup.py install


#

capture


from ghost import Ghost

ghost = Ghost()

page, resource=ghost.open("http://www.google.com")

ghost.capture_to('google.png')


#

snapshot



#

TroubleShooting


1. pyside 설치 오류 발생시

RuntimeError: Can't find '/usr/bin/pyside_postinstall.py'

http://stackoverflow.com/questions/16074801/pyside-install-fails-python-2-7-4


~/build/pyside에 pyside 소스가 이미 다운로드 되어 있다. 

$ cd ~/build

$ sudo chmod -R userid:userid pyside


egg 만들기

$ python setup.py bdist_egg --qmake=/usr/bin/qmake-qt4 


install

$ sudo easy_install dist/PySide-1.2.1-py2.7.egg

$ sudo python pyside_postinstall.py -install


Happy Coding~:)

#

SetupTools

$ wget http://pypi.python.org/packages/source/s/setuptools/setuptools-0.6c11.tar.gz#md5=7df2a529a074f613b509fb44feefe74e

$ tar xzvf setuptools-0.6c11.tar.gz

$ cd setuptools-0.6c11

install

$ sudo python setup.py install


#

pip 

$ wget http://pypi.python.org/packages/source/p/pip/pip-1.1.tar.gz#md5=62a9f08dd5dc69d76734568a6c040508

$ tar xzvf pip-1.1.tar.gz

$ cd pip-1.1

$ sudo python setup.py install


#

VirtualEnv

PIP를 설치하고 나면 이제 더이상 소스를 다운로드 받을 필요가 없으니 virtualenv는 pip를 이용한다.

$ sudo pip install virtualenv

새로운 Python환경 생성

$ virtualenv tesseract

새로 생성한 환경 활성화

$ source tesseract/bin/activate

activate는 기존에 activate했던 내용을 초기화(deactivate)하는 코드와

Python실행환경을 위한 환경변수들을 초기화 한다.

이제 shell의 prompt가 변경된다.

(tesseract)cjlee@cj-gear:~/proj$ 


이제 tesseract project를 위한 package들을 install하면 된다.


Happy Coding~:)




#
기본 encoding
file encoding이 지정되어 있지 않으면 ASCII로 처리

#
선언
파일의 첫번째 또는 두번째줄에 다음과 정규식을 만족하는 comment를 추가해서 encoding을 지정할 수 있다.

"coding[:=]\s*([-\w.]+)"
\s : 
[ \t\n\r\f\v]
whitespace(LOCALE, UNICODE flag가 지정되어 있지 않은 경우)
\w: 
[a-zA-Z0-9_]
any alphanumeric character and the underscore(LOCALE, UNICODE flag가 지정되어 있지 않은 경우)

즉 앞쪽에coding으로 시작해서 :,=가 나오고 
그뒤에 공백은 몇개가 나와도 상관없고
그다음에 encoding을 나타내는 문자열이 나온다.
 
valid format
*
# coding=<encoding  name>
 
*
#!/usr/bin/python
# -*- coding: <encoding name> -*-

*
#!/usr/bin/python
# vim: set fileencoding=<encoding name> :

#
예시
*
# coding:UTF-8
*
# coding=UTF-8
*
# vim:fileencoding=UTF-8

Happy Coding~:)

+ Recent posts