Uday kumar das
Uday kumar das

Reputation: 1613

Convert UTF-8 string to readable string

I have a UTF-8 string like:

a= "for ccps ‘the way forward’"

And want to convert to for CCPs ‘the way forward’

I tried code like:

CGI.escape a

Upvotes: 0

Views: 500

Answers (1)

Uday kumar das
Uday kumar das

Reputation: 1613

Finally got the solution:

a= "for ccps ‘the way forward’"
a.encode("cp1252").force_encoding("utf-8")

Upvotes: 1

Related Questions