welovewordpress / SublimePhpTidy

Plugin for Sublime Text 2 to format PHP code to meet the WordPress Coding Standards using a modified version of phptidy
GNU General Public License v2.0
109 stars 30 forks source link

Accents in comments make PhpTidy failed #28

Open potsky opened 11 years ago

potsky commented 11 years ago

Hi !

when accents are in comments, invoking PhpTidy gives these messages in the console :

PhpTidy: calling script: /opt/local/bin/php "/Users/potsky/Library/Application Support/Sublime Text 3/Packages/SublimePhpTidy/wp-phptidy.php" replace "/tmp/phptidy-sublime-buffer.php"
Traceback (most recent call last):
  File "/Applications/Sublime Text.app/Contents/MacOS/sublime_plugin.py", line 549, in run_
    return self.run(edit)
  File "/Users/potsky/Library/Application Support/Sublime Text 3/Packages/SublimePhpTidy/php_tidy.py", line 73, in run
    newContent = fileHandle.read()
  File "X/encodings/ascii.py", line 26, in decode
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 3592: ordinal not in range(128)
18601673727 commented 10 years ago

Well, I have the same issue with you.

carlos-mora commented 8 years ago

+1 The problem seems to be the double utf-8 encoding produced by line 49 in php_tidy.py: bufferContent = self.view.substr(bufferLength).encode('utf-8') this is unnecesary if the file is (the common situation for me) already utf-8 encoded