I have a browser which sends utf-8 characters to my Python server, but when I retrieve it from the query string, the encoding that Python returns is ASCII. How can I convert the plain string to utf-8?
NOTE: The string passed from the web is already UTF-8 encoded, I just want to make Python to treat it as UTF-8 not ASCII.
>>> plain_string = "Hi!" >>> unicode_string = u"Hi!" >>> type(plain_string), type(unicode_string) (<type "str">, <type "unicode">)
^ This is the difference between a byte string (plain_string) and a unicode string.
>>> s = "Hello!" >>> u = unicode(s, "utf-8")
^ Converting to unicode and specifying the encoding.
All strings are unicode. The
unicode function does not exist anymore. See answer from @Noumenon
A Practical Approach to Computer Algorithms Using Python® and C# Rod Stephens started out as a mathematician, but while studying at MIT, he discovered how much fun algorithms are. He took every al...
Vincent Bumgarner has been designing software for nearly 20 years, working in many languages on nearly as many platforms. He started using Splunk in 2007 and has enjoyed watching the product evolve ov...
You should understand the basics of development and usage atop Apache Spark. This book will not be covering introductory material. There are numerous books, forums, and resources available that cover ...
Topics on Big Data are growing rapidly. From the first 3 V’s that originally characterized Big Data, the industry now has identified 42 V’s associated with Big Data. The list of how we characteriz...