Solved

Problem with non-printable characters

Posted on 2013-06-30
3
491 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 83

Accepted Solution

by:
Dave Baldwin earned 500 total points
ID: 39288446
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
ID: 39288697
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 83

Expert Comment

by:Dave Baldwin
ID: 39288942
You're welcome, thanks for the points.
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

These days socially coordinated efforts have turned into a critical requirement for enterprises.
This article discusses how to create an extensible mechanism for linked drop downs.
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.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

920 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

17 Experts available now in Live!

Get 1:1 Help Now