Skip to content

Commit

Permalink
Fix issue #2: preserve control characters in unicode format
Browse files Browse the repository at this point in the history
  • Loading branch information
seanliang committed Sep 27, 2013
1 parent 82f131e commit caa1c8b
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion JavaPropertiesEditor.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ def __missing__(self, key):
LOWER_TABLE = LowerTable(enumerate(MAP))
IS_UPPER = re.compile('\\\\u([A-F][A-Z0-9]{3,3}|[0-9][A-F][A-F0-9]{2,2}|[0-9]{2,2}[A-F][A-F0-9]|[0-9]{3,3}[A-F])')

UNIC = '\\u000'
CTRL = '>LRTC<'

class JavaPropertiesConvertCommand(sublime_plugin.TextCommand):
def run(self, edit, contents):
view = self.view
Expand Down Expand Up @@ -56,7 +59,7 @@ def on_load(self, view):
return
regions = sublime.Region(0, view.size())
orignal_contents = view.substr(regions)
contents = orignal_contents.encode('iso-8859-1', 'replace').decode('raw_unicode_escape')
contents = orignal_contents.replace(UNIC, CTRL).encode('iso-8859-1', 'replace').decode('raw_unicode_escape').replace(CTRL, UNIC)
if contents == orignal_contents:
return
if IS_UPPER.search(orignal_contents) == None:
Expand Down

0 comments on commit caa1c8b

Please sign in to comment.