How to get string objects instead of Unicode from JSON?

I’m using Python 2 to parse JSON from ASCII encoded text files. When loading these files with either json or simplejson, all my string values are cast to Unicode objects instead of string objects. The problem is, I have to use the data with some libraries that only accept string objects. I can’t change the … Read more

Replace non-ASCII characters with a single space

I need to replace all non-ASCII (\x00-\x7F) characters with a space. I’m surprised that this is not dead-easy in Python, unless I’m missing something. The following function simply removes all non-ASCII characters: def remove_non_ascii_1(text): return ”.join(i for i in text if ord(i)<128) And this one replaces non-ASCII characters with the amount of spaces as per … Read more

SyntaxError: Non-ASCII character ‘\xa3’ in file when function returns ‘£’

Say I have a function: def NewFunction(): return ‘£’ I want to print some stuff with a pound sign in front of it and it prints an error when I try to run this program, this error message is displayed: SyntaxError: Non-ASCII character ‘\xa3’ in file ‘blah’ but no encoding declared; see http://www.python.org/peps/pep-0263.html for details … Read more

How to use unicode characters in Windows command line?

We have a project in Team Foundation Server (TFS) that has a non-English character (š) in it. When trying to script a few build-related things we’ve stumbled upon a problem – we can’t pass the š letter to the command-line tools. The command prompt or what not else messes it up, and the tf.exe utility … Read more

Representing Directory & File Structure in Markdown Syntax [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers. Want to improve this question? Update the question so it’s on-topic for Stack Overflow. Closed 1 year ago. Improve this question I want to describe directory & file structures in some of my Jekyll blog posts, does Markdown provide a … Read more

Placing Unicode character in CSS content value [duplicate]

This question already has answers here: Adding HTML entities using CSS content (9 answers) Closed 6 years ago. I have a problem. I have found the HTML code for the downwards arrow, &darr; (↓) Cool. Now I need to use it in CSS like so: nav a:hover {content:”&darr”;} That obviously won’t work since &darr; is … Read more