Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Problem with non-printable characters

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

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

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

Read about achieving the basic levels of HRIS security in the workplace.
Never store passwords in plain text or just their hash: it seems a no-brainier, but there are still plenty of people doing that. I present the why and how on this subject, offering my own real life solution that you can implement right away, bringin…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

840 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