codepages

How to get the code page of the current keyboard layout?

丶灬走出姿态 提交于 2019-12-06 13:37:55
My non-Unicode application needs to be able to process Unicode keyboard input (WM_CHAR/etc.), thus receive the 8-bit character code then internally convert it to Unicode. 9x-compatibility is required, so using most Unicode APIs is not an option. Currently it looks at the language returned by PRIMARYLANGID(GetKeyboardLayout(0)), and looks up the relevant code page in a hard-coded table. I couldn't find a function to get the code page used by a particular language or keyboard layout. Converting a character/string can then be done with MultiByteToWideChar. Is there a way to get the current

Convert string from codepage 1252 to 1250

末鹿安然 提交于 2019-12-06 07:21:38
问题 How can I convert one String with characters decoded in codepage 1252 into a String decoded in codepage 1250. For example String str1252 = "ê¹ś¿źæñ³ó"; String str1250 = convert(str1252); System.out.print(str1250); I want to find such convert() function, that printed output would be: ęąśżźćńłó These are Polish-specific characters. Thank you for any suggestions. 回答1: It's pretty straightforward: public String convert(String s) { return new String(s.getBytes("Windows-1252"), "Windows-1250"); }

How to use Delphi XE's TEncoding to save Cyrillic or ShiftJis text to a file?

↘锁芯ラ 提交于 2019-12-05 20:08:42
I'm trying to save some lines of text in a codepage different from my system's such as Cyrillic to a TFileStream using Delphi XE. However I can't find any code sample to produce those encoded file ? I tried using the same code as TStrings.SaveToStream however I'm not sure I implemented it correctly (the WriteBom part for example) and would like to know how it would be done elsewhere. Here is my code: FEncoding := TEncoding.GetEncoding(1251); FFilePool := TObjectDictionary<string,TFileStream>.Create([doOwnsValues]); //... procedure WriteToFile(const aFile, aText: string); var Preamble, Buffer:

Encoding ☺ as IBM-437 fails while other valid characters like é succeed

风格不统一 提交于 2019-12-05 14:20:12
☺: >>> bytes('☺','ibm437') Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/lib/python3.3/encodings/cp437.py", line 12, in encode return codecs.charmap_encode(input,errors,encoding_map) UnicodeEncodeError: 'charmap' codec can't encode character '\u263a' in position 0: character maps to <undefined> As opposed to é, which works: >>> bytes('é','ibm437') b'\x82' I expect ☺ to bring me back b'\x01' . How can I make this the case? An image of Code Page 437. IBM-437 is somewhat special in that it is not only a codepage (i.e. defines what should happen for byte values

How can I change console font?

僤鯓⒐⒋嵵緔 提交于 2019-12-05 12:32:52
I have a problem with output Unicode in Windows XP console. (Microsoft Windows XP [Version 5.1.2600]) First code is that(from http://www.siao2.com/2008/03/18/8306597.aspx ) #include #include #include int main(void) { _setmode(_fileno(stdout), _O_U16TEXT); wprintf(L"\x043a\x043e\x0448\x043a\x0430 \x65e5\x672c\x56fd\n"); wprintf(L"èéøÞǽлљΣæča\n"); wprintf(L"ぐႢ\n"); wprintf(L"\x3050\x10a0\n"); return 0; } My codepage is 65001(CP_UTF8). Excep Ⴂ, every letter look good. But Ⴂ is look like square. Console's default font 'Lucida Console' doesn't have font for that letter. So, I downloaded some other

Convert string from codepage 1252 to 1250

谁说我不能喝 提交于 2019-12-04 16:27:12
How can I convert one String with characters decoded in codepage 1252 into a String decoded in codepage 1250. For example String str1252 = "ê¹ś¿źæñ³ó"; String str1250 = convert(str1252); System.out.print(str1250); I want to find such convert() function, that printed output would be: ęąśżźćńłó These are Polish-specific characters. Thank you for any suggestions. axtavt It's pretty straightforward: public String convert(String s) { return new String(s.getBytes("Windows-1252"), "Windows-1250"); } Note that System.out.print() can introduce another incorrect conversion due to mismatch between ANSI

How to Convert UTF-8 Arabic letters to CodePage 1001?

别来无恙 提交于 2019-12-04 03:49:21
问题 I have a Star Micronics TSP that supports CodePage 1001 Arabic, how do I convert UTF-8 to that specific code page using C#? Update: I found out that CodePage 864 is compatible with the printer, I tried sending hex values and I got the correct character, myPrinter.PrintNormal(PrinterStation.Receipt, "\xFE8D"); I tried the following to convert a string to codePage 864: Encoding enc = Encoding.GetEncoding(864); byte[] arr = enc.GetBytes("السلام"); the byte arr values i'm getting after the

python Convert Encoding:LookupError: unknown encoding: ansi

依然范特西╮ 提交于 2019-12-04 03:47:08
Because of my encode of cdv file is "utf-8",so when I open it with excel it will cause distortion,and when I convert it to then standard encode "ANSI",I get the error: code: import chardet def convertEncoding(from_encode,to_encode,old_filepath,target_file): f1=file(old_filepath) content2=[] while True: line=f1.readline() content2.append(line.decode(from_encode).encode(to_encode)) if len(line) ==0: break f1.close() f2=file(target_file,'w') f2.writelines(content2) f2.close() convertFile = open('4321.csv','r') data = convertFile.read() print chardet.detect(data) if chardet.detect(data)['encoding'

C# ESC/POS Print Vietnamese

淺唱寂寞╮ 提交于 2019-12-04 03:40:54
问题 I have an application which print the receipt to receipt printer using ESC/POS. It needs to support multi-languages. Currently, I've tested with Chinese characters (both traditional and simplified) and Thai language. They all are working fine. However, when I tried to print Vietnamese, some of the characters are being replace by "?". Here is my code: public static readonly string ESC = "\u001B"; ... ... ... Encoding enc = Encoding.GetEncoding(1258); //vietnamese code page string content =

Running BAT/CMD file with accented characters in it

僤鯓⒐⒋嵵緔 提交于 2019-12-03 05:09:28
问题 I have a Windows batch file which has an instruction to execute an EXE file in a location whose path contains accented characters. Following are the contents of the batch file. @echo off C:\español\jre\bin\java.exe -version C:\español\jre\bin\java.exe - This path exists and is proper. I can run this command directly on cmd.exe. But when I run the command from a bat/cmd file it fails saying "The system cannot find the path specified" One way to fix this is by setting code page to 1252 (that