Project: appceleratorstudio
Issue TISTUD-1680: Better error hinting with regard to non-UTF-8 characters for android
h2. Problem When a non-UTF-8 character is found in a Titanium editor window, TiStudio will mark the file containing it with an error in the gutter. Doing a mouse over on this error reveals the following error message. {code:lang=none} File needs to be in UTF-8 encoding for Android. Decoding failed near byte 0. {code} Unfortunately for me, the non-UTF-8 character was no where near byte 0. It was actually at byte 1193 as shown in the Android error log when attempting to ignore TiStudio's error and run the application anyway: {code:lang=none} [ERROR] Exception occured while building Android project: [ERROR] Traceback (most recent call last): [ERROR] File "/Users/tlukasavage/Library/Application Support/Titanium/mobilesdk/osx/2.0.1.GA2/android/builder.py", line 2125, in [ERROR] s.build_and_run(True, avd_id, device_args=device_args) [ERROR] File "/Users/tlukasavage/Library/Application Support/Titanium/mobilesdk/osx/2.0.1.GA2/android/builder.py", line 1867, in build_and_run [ERROR] True, project_dir = self.top_dir, include_all_ti_modules=include_all_ti_modules) [ERROR] File "/Users/tlukasavage/Library/Application Support/Titanium/mobilesdk/osx/2.0.1.GA2/android/android.py", line 301, in create [ERROR] self.build_modules_info(resource_dir, app_bin_dir, include_all_ti_modules=include_all_ti_modules) [ERROR] File "/Users/tlukasavage/Library/Application Support/Titanium/mobilesdk/osx/2.0.1.GA2/android/android.py", line 170, in build_modules_info [ERROR] compiler.compile(compile_bytecode=False, info_message=None) [ERROR] File "/Users/tlukasavage/Library/Application Support/Titanium/mobilesdk/osx/2.0.1.GA2/android/compiler.py", line 250, in compile [ERROR] js_contents = self.make_function_from_file(fullpath) [ERROR] File "/Users/tlukasavage/Library/Application Support/Titanium/mobilesdk/osx/2.0.1.GA2/android/compiler.py", line 209, in make_function_from_file [ERROR] file_contents = codecs.open(path,'r',encoding='utf-8').read() [ERROR] File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/codecs.py", line 671, in read [ERROR] return self.reader.read(size) [ERROR] File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/codecs.py", line 477, in read [ERROR] newchars, decodedbytes = self.decode(data, self.errors) [ERROR] UnicodeDecodeError: 'utf8' codec can't decode byte 0xa9 in position 1311: invalid start byte {code} h2. Proposed Solution Return a byte position that more closely represents the location of the offending non-UTF-8 character. Also, if possible, move the error marker in the gutter from the first line of the file to the appropriate line in the file. h2. Test Case The following comments should be enough to show what I mean. The character after the word "Copyright" is the one causing the error, but TiStudio reports the error at byte 0. {code:javascript} // ========================================================================= // // xmlw3cdom.js - a W3C compliant DOM parser for XML for
Story points: 8