Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file not shown.
Binary file added Students/salim/session10/.unicode_lab.py.swp
Binary file not shown.
Binary file added Students/salim/session10/ICanEatGlass.utf161.txt
Binary file not shown.
23 changes: 23 additions & 0 deletions Students/salim/session10/ICanEatGlass.utf81.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
I Can Eat Glass:

And from the sublime to the ridiculous, here is a certain phrase in an assortment of languages:

Sanskrit: काचं शक्नोम्यत्तुम् । नोपहिनस्ति माम् ॥

Sanskrit (standard transcription): kācaṃ śaknomyattum; nopahinasti mām.

Classical Greek: ὕαλον ϕαγεῖν δύναμαι· τοῦτο οὔ με βλάπτει.

Greek (monotonic): Μπορώ να φάω σπασμένα γυαλιά χωρίς να πάθω τίποτα.

Greek (polytonic): Μπορῶ νὰ φάω σπασμένα γυαλιὰ χωρὶς νὰ πάθω τίποτα.

Latin: Vitrum edere possum; mihi non nocet.

Old French: Je puis mangier del voirre. Ne me nuit.

French: Je peux manger du verre, ça ne me fait pas mal.

Provençal / Occitan: Pòdi manjar de veire, me nafrariá pas.

Québécois: J'peux manger d'la vitre, ça m'fa pas mal.
Binary file added Students/salim/session10/example.db
Binary file not shown.
7 changes: 7 additions & 0 deletions Students/salim/session10/output_test.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

This is a unicode object. You can tell because I have a bunch of unicode
characters. Here are some examples:
ڴ
Isn't that cool!
7 changes: 7 additions & 0 deletions Students/salim/session10/output_test_2.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

This is a unicode object. You can tell because I have a bunch of unicode
characters. Here are some examples:
ڴ
Isn't that cool!
Empty file.
Binary file added Students/salim/session10/text1.utf16
Binary file not shown.
Binary file added Students/salim/session10/text1.utf32
Binary file not shown.
17 changes: 17 additions & 0 deletions Students/salim/session10/text1.utf8
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
Origin (in native language) Name (in native language)
Հայաստան Արամ Խաչատրյան
Australia Nicole Kidman
Österreich Johann Strauß
Azərbaycan Vaqif Səmədoğlu
Азәрбајҹан Вагиф Сәмәдоғлу
Azərbaycan Heydər Əliyev
Азәрбајҹан Һејдәр Әлијев
België René Magritte
Belgique René Magritte
Belgien René Magritte
বাংলা সুকুমার রায়
འབྲུག་ཡུལ། མགོན་པོ་རྡོ་རྗེ།
ប្រទេស​​​កម្ពុជា ព្រះ​ពុទ្ឋឃោសាចារ‌្យ​ជួន​ណាត
Canada Céline Dion
ᓄᓇᕗᒻᒥᐅᑦ ᓱᓴᓐ ᐊᒡᓗᒃᑲᖅ

49 changes: 49 additions & 0 deletions Students/salim/session10/unicode_lab.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#!/usr/bin/env python

import io
import os


# test printing unicode
print u'this is a snowman: \u2603'
print u'this is a snowflake: \u2744'
print u'this is a theta symbol: \u0398'


# test reading unicode
eat_glass_utf16 = io.open('ICanEatGlass.utf161.txt', encoding='utf-16')
print eat_glass_utf16.read()

eat_glass_utf8 = io.open('ICanEatGlass.utf81.txt', encoding='utf-8')
print eat_glass_utf8.read()

text1_utf32 = io.open('text1.utf32' ,encoding='utf-32')
print text1_utf32.read()

text1_utf16 = io.open('text1.utf16' ,encoding='utf-16')
print text1_utf16.read()

text1_utf8 = io.open('text1.utf8' ,encoding='utf-8')
print text1_utf8.read()


# test writing/reading unicode to files
try:
pwd = os.path.dirname(__file__)
except NameError:
pwd = os.getcwd()

s = u"""
This is a unicode object. You can tell because I have a bunch of unicode
characters. Here are some examples:
\t\u06B4
\t\u08A9
\t\u0A74
Isn't that cool!
"""

with io.open(os.path.join(pwd, 'output_test.txt'), 'w') as f: # io packagge
f.write(s)

with open(os.path.join(pwd, 'output_test_2.txt'), 'w') as f: # built in open
f.write(s.encode('utf-8')) # must encode before writing