ก่อนจะประมวลผลข้อความ เราจำเป็นต้องทำความสะอาดข้อความเสียหน่อย ทั่ว ๆ ไปที่จำเป็นต้องทำ ก็เช่น แปลง new line (\r\n หรือ \n), หรือแปลงให้อยู่ในชุดอักขระ (character set) ที่โปรแกรมใน processing pipeline จะทำงานได้ เช่นแปลง ä เป็น ae หรือแปลง “ ” เป็น ” “, หรือการ normalize ลำดับอักขระ เช่น น.หนู+สระอำ+ไม้โท → น.หนู+ไม้โท+สระอำ, หรือไปถึงขั้นซับซ้อน อย่างแก้ตัวสะกด
Tag: Unicode
encode("UTF-8", "ignore") ข้าม ๆ เรื่องที่ทำไม่ได้ใน Python
หลังจากเอา python-libthai ของวีร์มาใช้กับข้อมูลที่ได้มาจากเว็บ ก็พบปัญหาเรื่อง character encoding นิดหน่อย
Time for Unicode ?
เราควรจะเปลี่ยนไปใช้รหัสข้อมูลอะไรดี ? สำหรับเอกสารภาษาไทยในโลกยุคอินเทอร์เน็ต
จะ Windows-874, TIS-620 หรือ ISO-8859-11 ก็คงไม่เพียงพอแล้ว สำหรับโลกยุคอินเทอร์เน็ตและสังคมพหุภาษา แม้แต่เอกสาร “ภาษาไทย” ในปัจจุบันก็ยังมีตัวอักษรละตินหรือสัญลักษณ์พิเศษต่าง ๆ แทรกอยู่มากมาย ซึ่งบางตัวก็ไม่ได้มีอยู่ทั้งใน Windows-874, TIS-620 และ ISO-8850-11
Encodings/Charsets in Java
Encoding, Canadian Mind Products’s Java Glossary
a very detailed resources on encoding/charset-related stuffs in Java ละเอียดมาก
List of supported encodings, how to convert them, guide to Readers, other classes/methods, etc.
Plus, Unicode in Java by Jason Orendorff
(เมื่อคืนทดลองใช้ iBATIS (ORM ตัวนึง) กับภาษาไทยใน MySQL ไม่เวิร์กแฮะ ฟิลด์ไหนที่เป็นภาษาไทย get ออกมาแล้วกลายเป็น null หมดเลย)
Unicode characters in details
Unicode @ FileFormat.info
name, info, browser test page, outline (SVG), fonts that support, encoding, how to type it in Windows, Java and .NET properties
Unicode, XML, TEI, Ω and Scholarly Documents
โดย Yannis HARALAMBOUS เสนอที่ 16th International Unicode Conference, Amsterdam, 2000
สองตัวแรกส่วนใหญ่คงเคยได้ยินกันมาบ้างแล้ว อยากรู้รายละเอียด ลองอ่าน Unicode, XML
TEI คือ Text Encoding Initiative เป็นคล้ายๆ “ข้อแนะนำ” สำหรับการจัดเก็บข้อมูลในคอมพิวเตอร์ ก่อนหน้านี้ใช้ SGML ตอนนี้เริ่มค่อยๆ ปรับเปลี่ยนมาใช้ XML ละ
Character encoding issues
A tutorial on character code issues – covers many issues in character encoding
Germanic Lexicon Project:
- An introduction to character encoding issues – strategies for the issues
- Character encoding – list of characters with their coresponding code
Multiple Representations – normalization, canonical decompositions, compatibility decompositions, etc.
Linguistic Sorting – how characters are sorted in an Oracle environment
Unicode in MySQL – with PHP examples
Character Encoding and the Web – with Thai example: “เอกชัย ศรีวิชัย”สุดทน เจอเทปผี ซี.ดี.เถื่อนแย่งตลาด สั่งลูกน้องไล่กระทืบพ่อค้าขายซี.ดี.เถื่อน พร้อมประกาศลั่น ฝากบอกเอเย่นต์ใหญ่ว่า “เอกชัย สั่งให้ทำ” !
Unicode for Programmers (draft)
Short tutorials by Jason Orendorff.
With many clear examples of how to work with Unicode in Java and Python.
I like this illustration.
last updated: 1 March 2002, but things that they had referred to haven’t changed much since then.
Common Locale Data Repository
Common Locale Data Repository (CLDR) จัดทำโดยองค์กร Unicode เป็นฐานข้อมูล locale data กลาง ให้โปรแกรมอื่นๆ นำไปใช้ต่อ เพื่อให้แต่ละโปรแกรม มี locale data ที่ถูกต้องตรงกัน ใช้งานร่วมกันได้ และไม่สับสน
อ้างอิง L10n.opentle.org
เพิ่มเติม: พี่เทพ ตอบคำถาม เรื่องข้อมูลที่ OOo กับ CLDR ไม่ตรงกัน และบางแห่งน่าจะผิด
ThaiWrap รุ่น 5
(บล็อกเก่า ThaiWrap bookmarklet, Auto thaiWrap())
รายการเปลี่ยนแปลง:
- ตัวแบ่งคำ เปลี่ยนจาก <WBR> มาใช้ zero-width space (U+200B) แทน เนื่องจาก Opera ไม่รู้จัก <WBR>
- เพิ่มการตรวจเบราเซอร์ เพื่อข้ามการทำงานทั้งหมด ถ้าใช้ Internet Explorer (เหตุผล: 1. จะได้ไม่เสียเวลา เพราะ IE ตัดคำได้อยู่แล้ว 2. IE แสดงผล zero-width space ไม่ได้)
ตอนนี้ยังเหลือปัญหา เรื่องไม่ทำงานกับเฟรมที่ซ้อนเฟรม ไล่ DOM reference ตะกี้นี้ เจอละว่ามันผิดตรงไหน (เราไปใช้ window.frames ซึ่งมันจะส่งค่ากลับเฉพาะ frames ระดับบนสุดเท่านั้น, คาดว่า. นอกจากนั้น มันยังไม่อยู่ใน spec ด้วย – อันตราย) แต่ยังไม่รู้จะแก้ไง ขอค้นก่อน