unicode-literals

How to decode unicode raw literals to readable string?

允我心安 提交于 2019-12-18 11:19:57
问题 If I assign unicode raw literals to a variable, I can read its value: >>> s = u'\u0421\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u043e' >>> s u'\u0421\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u043e' >>> print s Сообщение отправлено But when I have already assigned value to a plain, not unicode string, I can not: >>> s = '\u0421\u043e\u043e\u0431\u0449\u0435\u043d\u0438

How to decode unicode raw literals to readable string?

白昼怎懂夜的黑 提交于 2019-12-18 11:18:55
问题 If I assign unicode raw literals to a variable, I can read its value: >>> s = u'\u0421\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u043e' >>> s u'\u0421\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u043e' >>> print s Сообщение отправлено But when I have already assigned value to a plain, not unicode string, I can not: >>> s = '\u0421\u043e\u043e\u0431\u0449\u0435\u043d\u0438

Unicode string literals in VBA

﹥>﹥吖頭↗ 提交于 2019-12-17 16:52:08
问题 I would like to declare (in a VBA class module) some private constant strings that contain Japanese characters. Is there a way to construct String literals (or combining literals in a way) that may be accepted as initializers in a Const declaration? i.e. something like: Private Const MY_CONST = ... or Private Const MY_CONST As String = ... I use MS Excel v14.0.6112.5000 (MS Office Professional Plus 2010). What won't work : Pasting the Japanese chars directly in a string literal (e.g. ... =

How to print literal unicode string in Javascript?

本秂侑毒 提交于 2019-12-06 15:18:53
问题 I have an array containing strings with special unicode characters: var a = [ ["a", 33], ["h\u016B", 44], ["s\u00EF", 51], ... ]; When I loop over this array: for (i=0;i<a.length;i++) { document.write(a[i][0] + "<br />"); } It prints characters with accents: a hù sô ... and I want: a h\u016B s\u00EF ... How can I achieve this in Javascript? 回答1: Something like this? /* Creates a uppercase hex number with at least length digits from a given number */ function fixedHex(number, length){ var str

Unicode string literals in C# vs C++/CLI

你说的曾经没有我的故事 提交于 2019-12-02 12:21:49
问题 C#: char z = '\u201D'; int i = (int)z; C++/CLI: wchar_t z = '\u201D'; int i = (int)z; In C# " i " becomes, just as I expect, 8221 ($201D). In C++/CLI on the other hand, it becomes 65428 ($FF94). Can some kind soul explain this to me? EDIT : Size of wchar_t can not be of issue here, because: C++/CLI: wchar_t z = (wchar_t)8221; int i = (int)z; Here too, i becomes 8221, so wchar_t is indeed up to the game of holding a 16-bit integer on my system. Ekeforshus 回答1: You want: wchar_t z = L'\x201D';

unicode_literals and doctest in Python 2.7 AND Python 3.5

本小妞迷上赌 提交于 2019-12-01 18:51:42
Consider the following demo script: # -*- coding: utf-8 -*- from __future__ import division from __future__ import unicode_literals def myDivi(): """ This is a small demo that just returns the output of a divison. >>> myDivi() 0.5 """ return 1/2 def myUnic(): """ This is a small demo that just returns a string. >>> myUnic() 'abc' """ return 'abc' if __name__ == "__main__": import doctest extraglobs = {} doctest.testmod(extraglobs=extraglobs) The doctest passes on Python 3.5, but fails on Python 2.7.9. The strange thing is, the divison test works, but the unicode test fails. I have seen various

Unicode (hexadecimal) character literals in MySQL

做~自己de王妃 提交于 2019-11-30 20:26:36
Is there a way to specify Unicode character literals in MySQL? I want to replace a Unicode character with an Ascii character, something like the following: Update MyTbl Set MyFld = Replace(MyFld, "ẏ", "y") But I'm using even more obscure characters which are not available in most fonts, so I want to be able to use Unicode character literals, something like Update MyTbl Set MyFld = Replace(MyFld, "\u1e8f", "y") This SQL statement is being invoked from a PHP script - the first form is not only unreadable, but it doesn't actually work! You can specify hexadecimal literals (or even binary literals

How to write unicode cross symbol in Java?

白昼怎懂夜的黑 提交于 2019-11-30 00:43:21
I'm trying to write this unicode cross symbol ( 𐀵 ) in Java: class A { public static void main(String[] args) { System.out.println("\u2300"); System.out.println("\u10035"); } } I can write o with a line through it ( ⌀ ) just fine, but the cross symbol doesn't show up, instead it just prints the number 5: # javac A.java && java A ⌀ ဃ5 Why? You're looking for U+10035, which is outside the Basic Multilingual Plane . That means you can't use \u to specify the value, as that only deals with U+0000 to U+FFFF - there are always exactly four hex digits after \u . So currently you've got U+1003 (

Unicode code point escapes in regex literals - Javascript

醉酒当歌 提交于 2019-11-29 14:32:22
Can this regex literal syntax having Unicode escape sequence syntax, var regpat= /^[\u0041-\u005A\u0061-\u007A\.\' \-]{2,15}/; be written using Unicode code point escape syntax(as shown below)? var regpat= /^[\u{41}-\u{5A}\u{61}-\u{7A}\u{1F4A9}\.\' \-]{2,15}/; Note: Unicode code point escapes is used to simplify ES5-compatible surrogate pair syntax representing code point value more than FFFF Yes, according to the spec this is now a valid escape sequence, however in order to enable support you must include the new u flag in the Regex definition: var regpat = /^[\u{41}-\u{5A}\u{61}-\u{7A}\u

How to print literal unicode string in Javascript?

二次信任 提交于 2019-11-29 11:35:05
问题 I have an array containing strings with special unicode characters: var a = [ ["a", 33], ["h\u016B", 44], ["s\u00EF", 51], ... ]; When I loop over this array: for (i=0;i<a.length;i++) { document.write(a[i][0] + "<br />"); } It prints characters with accents: a hù sô ... and I want: a h\u016B s\u00EF ... How can I achieve this in Javascript? 回答1: Something like this? /* Creates a uppercase hex number with at least length digits from a given number */ function fixedHex(number, length){ var str