“TypeError: (Integer) is not JSON serializable” when serializing JSON in Python?

I am trying to send a simple dictionary to a json file from python, but I keep getting the “TypeError: 1425 is not JSON serializable” message. import json alerts = {‘upper’:[1425],’lower’:[576],’level’:[2],’datetime’:[‘2012-08-08 15:30’]} afile = open(‘test.json’,’w’) afile.write(json.dumps(alerts,encoding=’UTF-8′)) afile.close() If I add the default argument, then it writes, but the integer values are written to the json … Read more

Why does the PHP json_encode function convert UTF-8 strings to hexadecimal entities?

I have a PHP script that deals with a wide variety of languages. Unfortunately, whenever I try to use json_encode, any Unicode output is converted to hexadecimal entities. Is this the expected behavior? Is there any way to convert the output to UTF-8 characters? Here’s an example of what I’m seeing: INPUT echo $text; OUTPUT … Read more

Unexpected = (equal sign) characters in wp mail

I have created a custom form for user registration and a custom html email when someone registers. $headers=”From: test<[email protected]>” . “\r\n”; $subject=”Test Subj”; $msg=”; $msg .= ‘ATTN: ‘.$fname.'<br><br>’; $msg .= ‘<strong>*Please confirm receipt of this message. If you are not the intended recipient, please notify us immediately.*</strong><br><br>’; $msg .= ‘The * is delighted to invite … Read more

Emojis getting converted to “?”

Emojis in posts and comments on a 500+ posts blog get converted automatically into single question marks in irregular and untraceable intervals. The respective tables wp_comments and wp_posts are configured to have a utf8mb4_unicode_ci collation, albeit in a latin1 / latin1_swedish_ci database, which (to my understanding) shouldn’t be a problem, as long as the tables … Read more

How do I determine file encoding in OS X?

I’m trying to enter some UTF-8 characters into a LaTeX file in TextMate (which says its default encoding is UTF-8), but LaTeX doesn’t seem to understand them. Running cat my_file.tex shows the characters properly in Terminal. Running ls -al shows something I’ve never seen before: an “@” by the file listing: -rw-r–r–@ 1 me users … Read more