user3620512
user3620512

Reputation: 39

UnicodeDecodeError: 'ascii' codec can't decode byte 0xbe in position 1

I'm getting error when I try to run file in cmd. When I run it in eclipse it works. Can't figure out where is the problem.. Eill you give me an advice?

getConnection
__init__
initialize
Traceback (most recent call last):
  File "D:\workspace\AproximateSearchPython2\Search.py", line 60, in <module>
    main()
  File "D:\workspace\AproximateSearchPython2\Search.py", line 57, in main
    search("weight")
  File "D:\workspace\AproximateSearchPython2\Search.py", line 24, in search
    levenshteinResults=SC.findMatchesByLevenshteinDistance(pattern) # Pre vstupy do 12 znakov
  File "D:\workspace\AproximateSearchPython2\SearchClass.py", line 39, in findMatchesByLevenshteinDistance
    levResults=list(automata.find_all_matches(pattern, k, matcher))
  File "D:\workspace\AproximateSearchPython2\automata.py", line 182, in find_all_matches
    next = lookup_func(match)
  File "D:\workspace\AproximateSearchPython2\automata.py", line 203, in __call__
    pos = bisect.bisect_left(self.l, w)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xbe in position 1: ordinal not in range(128)

Upvotes: 1

Views: 1142

Answers (1)

Medhat Gayed
Medhat Gayed

Reputation: 2813

You need to encode your string to utf-8 e.g:

u'my non ascii str'.encode('utf-8')

Upvotes: 1

Related Questions