convert tis-620 to utf-8 programing


เลยหาวิธี convert ในโปรแกรมของเราลองทำดูแล้ว work ดี 555 จดไว้ จดไว้ อันนี้เขียนด้วย c โดยรับอักขระเข้ามาทาง ไฟล์ pointer fp ซึ่งอาจจะมาจากไฟล์ จอภาพ หรือสายอักขระก็ได้ โดยไม่ได้ประกาศไว้ในตัวโค๊ด

int temp,temp2
while(((temp=getc(fp))!=’\n’)&&(!feof(fp))){
if(temp < 0×80){
*(text1+i) = temp; //ภาษาอังกฤษ เหมือนกัน ไม่เปลี่ยน
i++;
}else{
if ((0xA1<=temp && temp <= 0xDA )||(0xDF <= temp && temp <= 0xFB)){
temp2 = 0x0E00 + temp – 0xA0;
*(text1+i) = 0xE0 | (temp2 >> 12) ; //ส่วนภาษาไทยเพิ่มอีก เป็น 3 byte
*(text1+i+1) = 0×80 | ((temp2 >> 6) & 0x3F) ;
*(text1+i+2) = 0×80 | (temp2 & 0x3F) ;
i+=3;
}
}
}

จากการเขียนโปรแกรมคาราโอเกะบนลีนุก
ไอ้ไฟล์ lyr ของ nick karaoke มันดัด เก็บแบบ tis-620
แต่ ไอ้ SDL_ttf มันดันใช้รูปแบบเป็น utf-8 สำหรับภาษาไทย

** ดังนั้นไฟล์จะใหญ่ขึ้นประมาณ 3 เท่าอ่ะ

Enhanced by Zemanta

ใส่ความเห็น

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / เปลี่ยนแปลง )

Twitter picture

You are commenting using your Twitter account. Log Out / เปลี่ยนแปลง )

Facebook photo

You are commenting using your Facebook account. Log Out / เปลี่ยนแปลง )

Connecting to %s