Solved

Problem with non-printable characters

Posted on 2013-06-30
3
476 Views
Last Modified: 2013-06-30
Hello!

I've got a problem with some non-printable characters in a UTF-8 HTML document, specifically \u001f and \u001e.

I'm retrieving some data in JSON format, and using json_decode to convert the data into a PHP object.

It seems to be working fine, except those couple of characters. What's the best way to handle this?

I also have the ability to manipulate the data before it's packaged as a JSON string.

Thanks!
0
Comment
Question by:Julian Matz
  • 2
3 Comments
 
LVL 82

Accepted Solution

by:
Dave Baldwin earned 500 total points
Comment Utility
Those are the UTF-8 way of representing the 'RS' (0x1e) and 'US' (0x1f) ASCII control codes.  Those used to be used as separators in data streams.  If you have no use for them, you can just dump them.
0
 
LVL 21

Author Comment

by:Julian Matz
Comment Utility
I wasn't sure how to strip them, but figured it out with your help. Thank you.

str_replace( array( "\x1e", "\x1f" ), '', $string )

Open in new window

0
 
LVL 82

Expert Comment

by:Dave Baldwin
Comment Utility
You're welcome, thanks for the points.
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

APEX (Application Express) is used to develop a web application from Oracle. SQL Workshop is one of the tools that comes with Oracle APEX to query or modify the database objects or to make any changes to the structure.
Creating and Managing Databases with phpMyAdmin in cPanel.
The viewer will learn how to count occurrences of each item in an array.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now