Python convert string to unicode

0 votes
What program to use to read an ASCII string and to convert it to a unicode string encoded by utf-8?
Jul 10, 2019 in Python by Janan
1,641 views

1 answer to this question.

0 votes

Suppose you have a string in ASCII form you can encode it to utf-8 or utf-16 using encode function, please go through the below code snippet to do the same,

>>> x="String"
>>> x.encode('utf-8')
b'String'
>>> x.encode('utf-16')
b'\xff\xfeS\x00t\x00r\x00i\x00n\x00g\x00'
answered Jul 10, 2019 by Olivia

Related Questions In Python

0 votes
1 answer

Convert string to unicode in Python

Suppose you have a string in ASCII form ...READ MORE

answered Jul 23, 2019 in Python by Gani
12,896 views
+1 vote
5 answers

convert string to int python

Using list comprehensions: t2 = [map(int, list(l)) for ...READ MORE

answered Oct 18, 2018 in Python by donald
1,671 views
0 votes
1 answer

Python - convert string to list

try states.split() this would help. READ MORE

answered Jul 20, 2018 in Python by Priyaj
• 58,020 points
1,002 views
0 votes
1 answer

Python - convert string to list

states.split() will return ['Alaska', 'Alabama', 'Arkansas', 'American', 'Samoa', ...READ MORE

answered Jul 25, 2018 in Python by Frankie
• 9,830 points
815 views
0 votes
2 answers
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 7, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 4,423 views
0 votes
1 answer
+5 votes
6 answers

Lowercase in Python

You can simply the built-in function in ...READ MORE

answered Apr 11, 2018 in Python by hemant
• 5,790 points
4,043 views
0 votes
1 answer

How to convert date string to date object in python?

Use this :-  >>> datetime.datetime.strptime('24052010', "%d%m%Y").date() datetime.date(2010, 5, 24) Hope ...READ MORE

answered Oct 22, 2018 in Python by Priyaj
• 58,020 points
11,226 views
0 votes
1 answer

How to convert an integer to a string using Python?

Here is an easy solution: def numberToBase(n, b): ...READ MORE

answered Nov 23, 2018 in Python by Nymeria
• 3,560 points

edited Dec 12, 2018 by Nymeria 1,154 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP