How can I send Unicode characters (16 bit) with Serial port in Delphi 2010? -
i have problem in delphi 2010. send pc unicode (16 bits) characters printer serial port (com port). use tciacomport component in d2010.
for example:
ciacomport1.open := true; \\i open port data := #$0002 + unicodestring(Ж) + #$0003; ciacomport1.sendstr(parancs); //i send data device
if printer characterset ascii characters arrive, ciril character '?' on printer screen. if printer characterset unicode characters not arrive printer.
an unicode character represented in 2 bytes. how can decompose unicode character byte byte? example #$0002? , how can send strings byte byte comport? function?
under windows (check os how open , write comm ports), use following function write unicodestring comm port: bear in mind port have setup correctly, baud rate, number of bits, etc. see device manager => comm ports
function writetocommport(const sport:string; const soutput:unicodestring):boolean; var retw:dword; buff: pbyte; lenbuff:integer; fh:thandle; begin result:=false; lenbuff:=length(soutput)*2; if lenbuff = 0 exit; // nothing write, empty string fh:= windows.createfile(pchar(sport), generic_read or generic_write, 0, nil, open_existing, 0, 0); if (fh <> windows.invalid_handle_value) try buff:=pbyte(@soutput[1]); windows.writefile(fh, buff^, lenbuff, retw, nil); result:= integer(retw) = lenbuff; windows.closehandle(fh); end; end;
Comments
Post a Comment