diff options
author | Kyle Manna <kyle@kylemanna.com> | 2015-09-19 15:13:05 -0700 |
---|---|---|
committer | Kyle Manna <kyle@kylemanna.com> | 2015-09-20 18:53:15 -0700 |
commit | 03e3af597f0adf64b21731b820c997116a16cdcd (patch) | |
tree | f4b406bc14c4d567bb03bfa475fe8a011099d3f0 /generator | |
parent | 0d7ef5f936afc32bfe0aaec8b92667d4c3a026a0 (diff) |
generator: Strings are utf-8 by default in python3
* Not sure how to handle this case in python2, seems to work
* Python 3 doesn't need this since all strings are utf-8
Diffstat (limited to 'generator')
-rwxr-xr-x | generator/nanopb_generator.py | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/generator/nanopb_generator.py b/generator/nanopb_generator.py index f7d43221..78140a4c 100755 --- a/generator/nanopb_generator.py +++ b/generator/nanopb_generator.py @@ -379,12 +379,10 @@ class Field: inner_init = '0' else: if self.pbtype == 'STRING': - inner_init = self.default.encode('utf-8').encode('string_escape') - inner_init = inner_init.replace('"', '\\"') + inner_init = self.default.replace('"', '\\"') inner_init = '"' + inner_init + '"' elif self.pbtype == 'BYTES': - data = str(self.default).decode('string_escape') - data = ['0x%02x' % ord(c) for c in data] + data = ['0x%02x' % ord(c) for c in self.default] if len(data) == 0: inner_init = '{0, {0}}' else: |