Questions tagged [unicode-literals]

Use this tag for questions related to Unicode Literals. An example: ( u'some text' ), which is a different type of an object from a byte string ( 'some text' ).

is used in its general meaning, so make sure you provide a tag of your programming environment, if any, in your question.

For example in Python, quoting this answer:

A unicode literal ( u'some text' ) is a different type of Python object from a python byte string ( 'some text' ). It's like using \n versus \N ; the former has meaning in python literals (it's interpreted as a newline character), the latter just means a backslash and a capital N (two characters).

92 questions
102
votes
6 answers

Any gotchas using unicode_literals in Python 2.6?

We've already gotten our code base running under Python 2.6. In order to prepare for Python 3.0, we've started adding: from __future__ import unicode_literals into our .py files (as we modify them). I'm wondering if anyone else has been doing…
Jacob Gabrielson
  • 34,800
  • 15
  • 46
  • 64
70
votes
7 answers

How do I encode Unicode character codes in a PowerShell string literal?

How can I encode the Unicode character U+0048 (H), say, in a PowerShell string? In C# I would just do this: "\u0048", but that doesn't appear to work in PowerShell.
dan-gph
  • 16,301
  • 12
  • 61
  • 79
39
votes
2 answers

Unicode literals that work in python 3 and 2

So I have a python script that I'd prefer worked on python 3.2 and 2.7 just for convenience. Is there a way to have unicode literals that work in both? E.g. #coding: utf-8 whatever = 'שלום' The above code would require a unicode string in python…
ubershmekel
  • 11,864
  • 10
  • 72
  • 89
27
votes
4 answers

How to write unicode cross symbol in Java?

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…
Dog
  • 7,707
  • 8
  • 40
  • 74
26
votes
2 answers

How to decode unicode raw literals to readable string?

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' >>>…
gennad
  • 5,335
  • 12
  • 44
  • 47
21
votes
4 answers

How to print literal unicode string in Javascript?

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
Jérôme Verstrynge
  • 57,710
  • 92
  • 283
  • 453
20
votes
5 answers

python - how to add unicode literal to a variable?

I've seen some examples like this: for name in os.listdir(u'somedir') : my problem is that I'm getting the somedir as a variable, so how can I append the 'u' literal? something like for name in ops.listdir(u+somedir) ?
user1251654
  • 1,097
  • 4
  • 13
  • 21
18
votes
3 answers

Unicode literal string

I'm sending some JSON in an HTTP POST request. Some of the text within the JSON object is supposed to have superscripts. If I create my string in C# like this: string s = "here is my superscript: \u00B9"; ... it converts the \u00B9 to the actual…
user1373121
  • 999
  • 4
  • 13
  • 22
13
votes
1 answer

Unicode string literals

C++11 introduces a new set of string literal prefixes (and even allows user-defined suffixes). On top of this, you can directly use Unicode escape sequences to code a certain symbol without having to worry about encoding. const char16_t* s16 =…
rubenvb
  • 74,642
  • 33
  • 187
  • 332
12
votes
3 answers

Delphi2010: Writing code to assign Caption containing Unicode literal values or load unicode symbols from text file?

How to make a Unicode program in Delphi 2010? I have English Windows and "Current language for non-Unicode programs" is English too. Static controls look good but if I try to change them (Label.Caption := 'unicode value' or…
Michael
  • 475
  • 2
  • 9
  • 17
12
votes
1 answer

How to write 3 bytes unicode literal in Java?

I'd like to write unicode literal U+10428 in Java. http://www.marathon-studios.com/unicode/U10428/Deseret_Small_Letter_Long_I I tried with '\u10428' and it doesn't compile.
kawty
  • 1,656
  • 15
  • 22
11
votes
4 answers

Treat an emoji as one character in a regex

Here's a small example: reg = ur"((?P[+\-])(?P.+?))$" (In both cases the file has -*- coding: utf-8 -*-) In Python 2: re.match(reg, u"hello").groupdict() # => {u'initial': u'\ud83d', u'rest': u'\udc4dhello'} # unicode why must you do…
naiveai
  • 590
  • 2
  • 14
  • 42
9
votes
1 answer

Which Unicode character is used for the download sign?

What Unicode Icon / sign can we use that fits the idea of ​​file "download"? Is there a unique Unicode symbol?
Nmk
  • 1,281
  • 2
  • 14
  • 25
9
votes
3 answers

Unicode string literals in VBA

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?…
user2271770
8
votes
2 answers

Python unicode string literals :: what's the difference between '\u0391' and u'\u0391'

I am using Python 2.7.3. Can anybody explain the difference between the literals: '\u0391' and: u'\u0391' and the different way they are echoed in the REPL below (especially the extra slash added to a1): >>> a1='\u0391' >>> a1 '\\u0391' >>>…
Marcus Junius Brutus
  • 26,087
  • 41
  • 189
  • 331
1
2 3 4 5 6 7