473,383 Members | 1,801 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

How to convert ascii to text

I replace some user input with their ascii equivalent so they display
on the webpage properly:

$entry = preg_replace ( "/\'+/" , '&#39' , $entry);
$entry = preg_replace ( "/\,+/" , '&#44' , $entry);

I then need to email the data, however in email the ascii code is
displayed, not the text.
Is there an easier way to convert the ascii back to the text without
another preg_replace?

Dec 15 '06 #1
2 3087
ve*****@yahoo.com wrote:
I replace some user input with their ascii equivalent so they display
on the webpage properly:

$entry = preg_replace ( "/\'+/" , '&#39' , $entry);
$entry = preg_replace ( "/\,+/" , '&#44' , $entry);

I then need to email the data, however in email the ascii code is
displayed, not the text.
Is there an easier way to convert the ascii back to the text without
another preg_replace?
There really doesn't seem to be any reason you have to manually escape
the string with a regular expression, then change it back. Especially
since you're only accounting for a small set of characters that might
have problems. Why not leave the variable exactly as entered by the
user, and just run it through the "htmlspecialchars()" function when
you want to display it on the page?

http://us2.php.net/manual/en/functio...ecialchars.php

Dec 15 '06 #2
ve*****@yahoo.com wrote:
>
I replace some user input with their ascii equivalent so they display
on the webpage properly:

$entry = preg_replace ( "/\'+/" , '&#39' , $entry);
$entry = preg_replace ( "/\,+/" , '&#44' , $entry);
Are you aware that this will replace a string of quotes ('''''') or commas
(,,,,,,,) with a single &#39 or &#44? I'm pretty sure you don't want the
plus signs in there.

I assume this wasn't cut-and-pasted from your code, because the entities
must have trailing semicolons: '

Also, there is no reason to quote a comma. What led you to do that?
--
Tim Roberts, ti**@probo.com
Providenza & Boekelheide, Inc.
Dec 16 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Nathan | last post by:
Is there a way to convert a string to a CipherMessage? I am calling a function that decrypts a CipherMessage and returns the value. The only problem is when I want to use an encrypted value stored...
6
by: Ricardo Quintanilla | last post by:
i have a code that sends data to a socket listening over as400 platform, the socket responds to me as a "byte array". then i need to convert the "byte array" into a string. the problem is that...
7
by: MilanB | last post by:
Hello How to convert char to int? Thanks
8
by: davihigh | last post by:
My Friends: I am using std::ofstream (as well as ifstream), I hope that when i wrote in some std::string(...) with locale, ofstream can convert to UTF-8 encoding and save file to disk. So does...
8
by: csanjith | last post by:
Hi, i have a situaion where i need to convert the characters entered in an text field to upper case using C. The configuration id utf8 environment in which user can enter any character (single ,...
7
by: Joris De Groote | last post by:
Hi, I have a 1 dimensional table byte with a number af characters in ASCII code. How do I convert those ASCII codes to real letters? Thanks
6
by: as400tips | last post by:
I have a Binary Data file (Packed Decimal and ASCII mixed) and would like to convert into ASCII (readable) file. How to do it in C#? Thanks.
4
by: meendar | last post by:
Hi, I am having a character pointer which contains ascii values. i just want to convert all these ascii values to respective characters and again store it in another character pointer. ...
12
by: aatif | last post by:
I want to convert a string of hex characters (2 hex chars = 1 byte), to ASCII. Hex chars include zeros (0x00) as well, which I want to include in ASCII string. hex string: 5000005355.... ASCII:...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.