Sublime Forum

Output Hex values in Console

#1

I’m using Sublimetext 2 and I would like to see hex values directly in the build results.

Screenshot of encoding error I get


Screenshot of hex values getting displayed in console

Buildsystem JSON

{
	"cmd": "python2.7", "-u", "$file"],
	"path": "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/bin/",
	"file_regex": "^ ]*File \"(...*?)\", line ([0-9]*)",
	"selector": "source.python"
}

Is Console (Ctrl `) totally different from where build system shows the result (Cmd B)?

0 Likes

#2

Yes they are two separate things. They are both views, but the console is displaying a python interpreter, while the build system is a view with text in it. You may be able eto force ST to give the behavior you want though. Take a look at “Packages/Default/exec.py”.

0 Likes

#3

What should I be doing with exec.py? I’m just a beginner in python can you help me please.

0 Likes

#4

I’m not clear on what you want to see. format will produce the human-readable hex, so there’s no need to decode that. If you actually want the output to show the string-literal format like the Python interpreter shows, you might be best just to add the \x escapes yourself. I kind of doubt that’s what you really want, but it could be done like:

[code]import re
x = 65535
hex_string = format(x, ‘x’)

Raw hex

print hex_string

A string-literal

print “’” + re.sub(r’(…)’, r’\x\1’, hex_string) + “’”
[/code]

0 Likes