SUMOD SUNDAR
SUMOD SUNDAR

Reputation: 11

Using Malayalam unicode in python

The code:

import unicodedata
s=u'കക'
b=s.encode('utf-8').decode('utf-8')
print(b)

produced correct output in Python 3.0 shell as കക. But when i tried the same in Spyder(Python 2.7) (Set as default encoding scheme utf-8), it showed error as:

return codecs.charmap_encode(input,errors,encoding_table) UnicodeEncodeError: 'charmap' codec can't encode characters in position 0-1: character maps to <undefined>

please provide a solution.

Upvotes: 1

Views: 2280

Answers (1)

Ahmad Yoosofan
Ahmad Yoosofan

Reputation: 981

The following code produces correct output in Ubuntu 14.04 and Python 2.7.6

#!/usr/bin/python
# -*- coding: utf_8 -*-
import unicodedata
s=u'കക'
b=s.encode('utf-8').decode('utf-8')
print(b)

കക

Upvotes: 3

Related Questions