Comments (3)
Are you sure the source file is encoded as UTF-16? It definitely won't
parse a single-byte encoded file using a double-byte decoder.
(Chris)
On Tue, Jul 2, 2013 at 1:49 PM, Nick Portelli [email protected]:
I'm a bit unfamiliar with utf, but is there a reason why it won't parse if
it is utf-16?—
Reply to this email directly or view it on GitHubhttps://github.com//issues/41
.
from sublimetext_indentxml.
I'm not sure. I think it is whatever the default .net serializer we are using does. All I need to do is change 16 to 8 and your plugin works great. So in all reality not the plugin's issue. I should figure out how to make the thing save in utf-8. Go ahead and close this.
from sublimetext_indentxml.
I had the same issue, I temporary change remove the utf-16 from xml declaration and add it back before returning formatted string. Not sure this can be a fixer. Test on sublime 3. Find "fix:" in followed code...
class IndentXmlCommand(BaseIndentCommand):
def indent(self, s):
# convert to utf
s = s.encode("utf-8")
xmlheader = re.compile(b"<\?.*\?>").match(s)
# fix: replace header
if xmlheader:
s = s.replace(xmlheader.group(), '<?xml version="1.0"?>')
# convert to plain string without indents and spaces
s = re.compile(b'>\s+([^\s])', re.DOTALL).sub(b'>\g<1>', s)
# replace tags to convince minidom process cdata as text
s = s.replace(b'<![CDATA[', b'%CDATAESTART%').replace(b']]>', b'%CDATAEEND%')
try:
s = parseString(s).toprettyxml()
except Exception as e:
sublime.active_window().run_command("show_panel", {"panel": "console", "toggle": True})
raise e
# remove line breaks
s = re.compile('>\n\s+([^<>\s].*?)\n\s+</', re.DOTALL).sub('>\g<1></', s)
# restore cdata
s = s.replace('%CDATAESTART%', '<![CDATA[').replace('%CDATAEEND%', ']]>')
# remove xml header
s = s.replace("<?xml version=\"1.0\" ?>", "").strip()
if xmlheader:
s = xmlheader.group().decode("utf-8") + "\n" + s
return s
from sublimetext_indentxml.
Related Issues (20)
- format json with decimal number is wrong HOT 1
- Invalid XML not well-formed (invalid token) HOT 2
- Fail to indent with error "AttributeError: 'module' object has no attribute 'messages'" HOT 1
- Feature Request: Un-Indent HOT 2
- ValueError: multi-byte encodings are not supported HOT 1
- Add support or mode to allow undefined namespaces
- TypeError: String required when indenting xml with namespaces HOT 5
- Trouble installing HOT 4
- Make a more friendly Installation HOT 2
- Not work at all HOT 2
- After installing, cannot use, "Indent XML" is greyed out HOT 5
- Support Minify XML
- Package does not show up in the package manager search HOT 4
- Sublime V3 does not work HOT 5
- Indent XML does not appear for SVG files
- Support formatting XML pieces inside of other lnaguages
- Indent changes an " into an ' HOT 1
- Do not adjust adjust whitespace other than indent
- Doesn't format on save HOT 2
- larger data sets won't indent HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sublimetext_indentxml.