What does the 'u' indicate in the GCP Firestore API examples?

Viewed 47

The u is present in front of every value in the following example:

enter image description here

1 Answers

The ‘u’ in front of a string means the string is a Unicode string.

A Unicode is a way for a string to represent more characters than a regular ASCII string can.

In Python 2.x shell, you can see how for example a text written in Russian converts to a Unicode string with ‘u’ in front of it and a bunch of Unicode characters in it:

>>> hello_rus = u"Привет, мир"
>>> hello_rus
u'\u041f\u0440\u0438\u0432\u0435\u0442, \u043c\u0438\u0440'

In Python 2.x, a Unicode string is marked with ‘u’.

However, in Python 3 all strings are Unicode strings by default. Thus you will never see ‘u’ in front of a Unicode string in Python 3.

Content copied from: Python What Does ‘u’ Mean in Front of a String

Related