ภาษาไทยใน Python GUI

  • warning: realpath() [function.realpath]: SAFE MODE Restriction in effect. The script whose uid is 1005 is not allowed to access /tmp owned by uid 0 in /var/www/sites/sugree/codenone.com/subdomains/www/html/includes/file.inc on line 190.
  • warning: realpath() [function.realpath]: SAFE MODE Restriction in effect. The script whose uid is 1005 is not allowed to access /tmp owned by uid 0 in /var/www/sites/sugree/codenone.com/subdomains/www/html/includes/file.inc on line 190.

สร้างโปรแกรมอ่านค่าจาก txt file ค่ะซึ่งมีภาษาไทยอยู่ด้วย แต่พอ display ใน Python GUI ปรากฏเป็นภาษาต่างดาวอ่ะค่ะ รบกวนช่วยแนะนำวิธีแก้ไขด้วยนะคะ

source(txt file)
>>>สวัสดีไทยแลนด์

Code .py
>>># -*- encoding: utf-8 -*-
>>>#!/usr/bin/env python
>>>dataSource = file( "tam.txt", "r" )
>>>for addr in dataSource:
>>> addr.strip()
>>> print addr
>>>dataSource.close()

ผลลัพธ์ในหน้า Python GUI
>>>ÊÇÑÊ´Õä·ÂᏴì

khao_lek's picture

ขอบคุณ คุณkhao_lek มากค่ะ ใช้งานได้แล้วค่ะ โดยเพิ่ม decode(‘tis-620’) เข้าไปค่ะ

ย้าย Codenone

ประกาศย้าย Codenone ไปใช้ Forum ของ Blognone แทนครับ ตามไปตั้งกระทู้ต่อได้ที่ Codenone Forum (รายละเอียดอ่านจากกระทู้ ย้าย Codenone ไปรวมกับ Blognone)

กระทู้เก่าๆ จะย้ายตามไปในภายหลัง ตอนนี้ปิดการโพสต์กระทู้ไว้ เหลือไว้เฉพาะอ้างอิงเท่านั้น