UltiSnips crashed while trying to use non-ASCII UTF-8 character in snippet (feature request?)
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
UltiSnips |
Fix Released
|
Critical
|
Unassigned |
Bug Description
I tried to define some snippets with non-english characters, I tried for example Croatian characters "č", "ć" etc. When I tried to use those snippets during expansion of the trigger I immediately got stack-trace and notification that error has occurred.
Here's the stack trace:
> Following is the full stack trace:
> Traceback (most recent call last):
> File "/home/
> return f(*args, **kwds)
> File "/home/
> snippet = self._ask_
> File "/home/
> rv = vim.eval(
> File "/home/
> return conv(inp)
> File "/home/
> return u'[' + u",".join([conv(o) for o in obj]) + u']'
> File "/home/
> return u'"%s"' % str(obj)
> UnicodeDecodeError: 'ascii' codec can't decode byte 0xc4 in position 18: ordinal not in range(128)
Ok, I see now that UltiSnips use 'ascii' codec and since above mentioned characters are not in ascii-set they are not decoded. So this should probably be expected behavior of UltiSnips and not strictly a bug; nevertheless I would like to file this as a feature-request if I may. :) Great job with plugin, kicks ass!
Hi and thanks for the bug report. The handling of unicode is generally not easy and it is even more complicated in our case as there is no documentation which encoding vim.eval expects of its strings. After your bug report, I improved upon the situation by converting more explicitily between unicode and utf-8 encoded strings in UltiSnips - this results that german umlauts work for me now in my snippets. This should help you as well.
Unfortunately, the explicit conversion to and from utf-8 might make trouble if the snippet definition files are not encoded in utf-8 or if some vim version expects another encoding for vim.eval - I do not know how to fix this properly for the moment, therefore this 80% must do.
The fix is in r324 in trunk; it would be cool if you could test it and report back.