GoTop
GoTop

Reputation: 913

How to encode Django Exception Value like "\xce\xa5\xb7\xb4\xc1\xcb" to make it humreadable

My Django project Exception Value show in the browser is like this:

Exception Value:

('23000', "[23000] [Microsoft][SQL Native Client][SQL Server]\xce\xa5\xb7\xb4\xc1\xcb PRIMARY KEY \xd4\xbc\xca\xf8 'PK_Station_30F848ED'\xa1\xa3\xb2\xbb\xc4\xdc\xd4\xda\xb6\xd4\xcf\xf3 'dbo.Station' \xd6\xd0\xb2\xe5\xc8\xeb\xd6\xd8\xb8\xb4\xbc\xfc\xa1\xa3 (2627) (SQLExecDirectW); [01000] [Microsoft][SQL Native Client][SQL Server]\xd3\xef\xbe\xe4\xd2\xd1\xd6\xd5\xd6\xb9\xa1\xa3 (3621)")

how to format the hex string like "\xce\xa5\xb7\xb4\xc1\xcb" to human readable string?

Upvotes: 0

Views: 179

Answers (1)

Kowalski
Kowalski

Reputation: 76

you can use:

unicode(yourstring, "gb2312")

or

yourstring.decode("gb2312")

Upvotes: 0

Related Questions