unicode

Using WriteConsoleOutput to write Unicode with c#

被刻印的时光 ゝ 提交于 2020-07-10 03:40:14
问题 I am trying to use the WriteConsoleOutput function from kernel32.dll, however I cannot get unicode characters to display correctly, they always display as the wrong characters. I have attempted to use: Console.OutputEncoding = System.Text.Encoding.UTF8; Changing this to Encoding.Unicode does not work either. [DllImport("kernel32.dll", SetLastError = true)] private static extern bool SetConsoleOutputCP(uint wCodePageID); public void SetCP(){ SetConsoleOutputCP(65001); } I have tried using both

Using WriteConsoleOutput to write Unicode with c#

孤者浪人 提交于 2020-07-10 03:40:11
问题 I am trying to use the WriteConsoleOutput function from kernel32.dll, however I cannot get unicode characters to display correctly, they always display as the wrong characters. I have attempted to use: Console.OutputEncoding = System.Text.Encoding.UTF8; Changing this to Encoding.Unicode does not work either. [DllImport("kernel32.dll", SetLastError = true)] private static extern bool SetConsoleOutputCP(uint wCodePageID); public void SetCP(){ SetConsoleOutputCP(65001); } I have tried using both

Using WriteConsoleOutput to write Unicode with c#

大城市里の小女人 提交于 2020-07-10 03:40:06
问题 I am trying to use the WriteConsoleOutput function from kernel32.dll, however I cannot get unicode characters to display correctly, they always display as the wrong characters. I have attempted to use: Console.OutputEncoding = System.Text.Encoding.UTF8; Changing this to Encoding.Unicode does not work either. [DllImport("kernel32.dll", SetLastError = true)] private static extern bool SetConsoleOutputCP(uint wCodePageID); public void SetCP(){ SetConsoleOutputCP(65001); } I have tried using both

N-curses within Python : how to catch and print non ascii character?

妖精的绣舞 提交于 2020-07-09 19:56:07
问题 I want to make a small program with ncurses/python and to be able to use/type in french and japanese. I understand that I should set the locale and use unicode standard. But how to deal with the result from screen.getch() ? I would like to display the typed character within the ncurses window regardless of the language. I understand that some unicode conversion is necessary but can't find what to do (and i've searched quite a bit : this character conversion bussiness isnt easy to understand

N-curses within Python : how to catch and print non ascii character?

我的未来我决定 提交于 2020-07-09 19:54:23
问题 I want to make a small program with ncurses/python and to be able to use/type in french and japanese. I understand that I should set the locale and use unicode standard. But how to deal with the result from screen.getch() ? I would like to display the typed character within the ncurses window regardless of the language. I understand that some unicode conversion is necessary but can't find what to do (and i've searched quite a bit : this character conversion bussiness isnt easy to understand

Is there a Unicode alternative to OutputDebugString?

夙愿已清 提交于 2020-07-08 14:52:47
问题 OutputDebugString() is native ASCII, which means it convert the input Unicode string to local string before call the ASCII version OutputDebugStringA() . Is there any alternative to OutputDebugString() which supports Unicode? 回答1: OutputDebugStringW does internally call OutputDebugStringA , so Unicode characters that cannot be represented in the system code page will be replaced with ? . Oddly enough, the OUTPUT_DEBUG_STRING_INFO structure the debugger receives from the operating system to

Cut an UTF8 text in PHP

匆匆过客 提交于 2020-07-06 12:29:08
问题 I get UTF8 text from a database, and I want to show only the first $len characters (finishing in a word). I've tried several options but the function still doesn't work because of special characters (á, é, í, ó, etc). Thanks for the help! function text_limit($text, $len, $end='...') { mb_internal_encoding('UTF-8'); if( (mb_strlen($text, 'UTF-8') > $len) ) { $text = mb_substr($text, 0, $len, 'UTF-8'); $text = mb_substr($text, 0, mb_strrpos($text," ", 'UTF-8'), 'UTF-8'); ... } } Edit to add an

Convert between std::u8string and std::string

喜你入骨 提交于 2020-07-05 01:48:47
问题 C++20 added char8_t and std::u8string for UTF-8. However, there is no UTF-8 version of std::cout and OS APIs mostly expect char and execution character set. So we still need a way to convert between UTF-8 and execution character set. I was rereading a char8_t paper and it looks like the only way to convert between UTF-8 and ECS is to use std::c8rtomb and std::mbrtoc8 functions. However, their API is extremely confusing. Can someone provide an example code? 回答1: At present, std::c8rtomb and

Weird leading characters utf-8/utf-16 encoding in Python

柔情痞子 提交于 2020-07-03 11:54:29
问题 I have written a simplified version to demonstrate the problem. I am encoding special characters in utf-8 and UTF-16 format. With utf-8 encoding there is no problem, when I am encoding with UTF-16 I get some weird leading characters. I tried to remove all trailing and leading characters but still the error persists. Sample of code: #!/usr/bin/env python2 # -*- coding: utf-8 -*- import chardet def myEncode(s, pattern): try: s.strip() u = unicode(s, pattern) print chardet.detect(u.encode

Weird leading characters utf-8/utf-16 encoding in Python

两盒软妹~` 提交于 2020-07-03 11:53:27
问题 I have written a simplified version to demonstrate the problem. I am encoding special characters in utf-8 and UTF-16 format. With utf-8 encoding there is no problem, when I am encoding with UTF-16 I get some weird leading characters. I tried to remove all trailing and leading characters but still the error persists. Sample of code: #!/usr/bin/env python2 # -*- coding: utf-8 -*- import chardet def myEncode(s, pattern): try: s.strip() u = unicode(s, pattern) print chardet.detect(u.encode