...

View Full Version : how translate unicode to Thai by JavaScript



nuanpan2
03-18-2009, 10:40 AM
Hi there, I'm trying to write API using JavaScript for Winpos Printer now the printer can print out in English characters but I would like it to print out in Thai character. I have tried to do the code page setting like MSComm1.Output= '\x1B\x7422; which 22 means Thai code page but it still cannot print in Thai. The character printed out is like the alian charaters. Could anyone help me how to get the printer to print in Thai characters please?

Thank you everyone for helping me

Philip M
03-18-2009, 01:43 PM
Did you see Thai characters when you enter in the browser? If so, when you print it should be OK.

If you didn't see Thai characters in the browser, you need to change the browser codepage to include Thai (Windows). Select - Tools > Internet Options > Languages (add) > Thai.

That assumes that your print is capable of printing Thai or non-Roman characters.

abduraooft
03-18-2009, 01:57 PM
I think you'd need to follow



Install at least one Unicode font in your system, associated with the language that you want to view correctly, or install a Unicode font which contains large character set for many different languages.
Go to Start > Control Panel.
If you are in "Category View" select the icon that says "Date, Time, Language and Regional Options" and then select "Regional and Language Options".
If you are in Classic View select the icon that says "Regional and Language Options".
Select the "Languages" tab and make sure you select the option saying "Install files for complex script and right-to-left languages (including Thai)". A confirmation message should now appear - press "OK" on this confirmation message.
Allow the OS to install necessary files from the Windows XP CD and then reboot if prompted.

nuanpan2
03-18-2009, 02:48 PM
Thank you for your response "abduraooft" and "Philip M". I have to sorry that I haven't explained my problem clearly. My computer can write and display Thai char properly.

My situation is: I have to press Print button on HTML page which include .js and calls the function within .js file. All the printing style function like line spacing, underlining, and paper cutting will be called from .js file. Also the contents I am going to print out including in .js file.

Now, I got 2 files: printer.html and printer.js
printer.js sample code:


var MSComm1= new ActiveXObject("MSCommLib.MSComm.1");

// RS-232C port# 1 Baud Rate= 9600 bps, Data bit=8, Stop bit=1, No Parity bit
var CommPort=1;
var DataBit=8;
var StopBit=1;
var BaudRate=9600;
var n;
// Initialization of printer, clear buffer
var CmdA='\x1B\x40';
// Carriage Return, print buffer, and line feed
var CmdCRLF='\x0D\x0A';
// Cut Paper
var CmdCut='\x1D\x56\x01';

// Select the character code table
function CmdCodePage(n){
return '\x1B\x74'+'n';
}

function CheckPort(){
if(MSComm1.PortOpen!=true)
{
MSComm1.CommPort= CommPort;
MSComm1.Settings= BaudRate+',n,'+DataBit+','+StopBit;
MSComm1.Handshaking=0;
MSComm1.InputLen=0;
MSComm1.PortOpen = true;
PaperPrint();
}
else alert('Port has been opened!'); // just for testing
PaperPrint();
}

// function to test printing
function PaperPrint(){
MSComm1.Output=CmdA;
MSComm1.Output=CmdCodePage(22);
MSComm1.Output='WP-K833 ภาษาไทย';
MSComm1.Output = CmdCRLF;
MSComm1.Output = CmdCut;
MSComm1.Output = CmdCRLF;

}


And Html file only has a button call function CheckPort(). After clicking the button, the printer prints out "WP-K833" and not following by "ภาษาไทย" but something else not Thai.

Please anyone help me fix this out.

Thank you



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum