r284988 - Fix clang-format vim integration issue with non-ascii characters
Alexander Kornienko via cfe-commits
cfe-commits at lists.llvm.org
Mon Oct 24 09:31:26 PDT 2016
Author: alexfh
Date: Mon Oct 24 11:31:26 2016
New Revision: 284988
URL: http://llvm.org/viewvc/llvm-project?rev=284988&view=rev
Log:
Fix clang-format vim integration issue with non-ascii characters
clang-format.py currently seems to treat vim.current.buf as ascii-encoded data,
which leads to an UnicodeDecodeError when trying to format any text containing
non-ascii characters:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File ".../tools/clang/tools/clang-format/clang-format.py", line 110, in <module>
main()
File ".../tools/clang/tools/clang-format/clang-format.py", line 87, in main
stdout, stderr = p.communicate(input=text.encode(encoding))
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 3996: ordinal not in range(128)
Modified:
cfe/trunk/tools/clang-format/clang-format.py
Modified: cfe/trunk/tools/clang-format/clang-format.py
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-format/clang-format.py?rev=284988&r1=284987&r2=284988&view=diff
==============================================================================
--- cfe/trunk/tools/clang-format/clang-format.py (original)
+++ cfe/trunk/tools/clang-format/clang-format.py Mon Oct 24 11:31:26 2016
@@ -52,7 +52,7 @@ def main():
# Get the current text.
encoding = vim.eval("&encoding")
buf = vim.current.buffer
- text = '\n'.join(buf)
+ text = unicode('\n'.join(buf), encoding)
# Determine range to format.
if vim.eval('exists("l:lines")') == '1':
More information about the cfe-commits
mailing list