473,394 Members | 1,759 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,394 software developers and data experts.

Convert all characters to ISO-8859-1?

I have a script that posts text to the USENET. Occasionally, when someone
cuts and pastes text into the form field, they cut and paste a character
that isn't part of charset ISO-8859-1, such as a curly looking single
quote, etc.

I did some searching, but couldn't find and php function that would filter
this? Is there anything anyone has written, something like:

$string = convert_charset($string,ISO-8859-1);

?

If not, what else could I do to do this? (Yes I realize some of the
problems involved.)

--
[ Sugapablo ]
[ http://www.sugapablo.com <--music ]
[ http://www.sugapablo.net <--personal ]
[ su*******@12jabber.com <--jabber IM ]

Jul 17 '05 #1
3 3832
Sugapablo wrote:
I have a script that posts text to the USENET. Occasionally, when someone
cuts and pastes text into the form field, they cut and paste a character
that isn't part of charset ISO-8859-1, such as a curly looking single
quote, etc.


http://www.php.net/iconv does encoding conversions, but chances are
that's not quite what you're looking for.

I've found that certain characters break form-submissions from Internet
Explorer (certain fields in the form are lost - don't ask me why) -
ironically enough it only affects IE, and the reason the characters are
a problem is because they're put in by Microsoft Word's autocorrect - so
I've made a function that removes all these characters.

The characters are ascii 150 (the long hyphen), 148 (smart-quote), 146
(single smart-quote) and 133 (tripple dots). So I just do this:

str_replace(chr(150), "-", str_replace(chr(148), '"',
str_replace(chr(146), "'", str_replace(chr(133), "...", $text))));

And an equivalent client-side version called by onsubmit on the form,
and no more problem :)
Roy W. Andersen
--
ra at broadpark dot no / http://roy.netgoth.org/

"Hey! What kind of party is this? There's no booze
and only one hooker!" - Bender, Futurama
Jul 17 '05 #2
Sugapablo wrote:
I have a script that posts text to the USENET. Occasionally, when someone cuts and pastes text into the form field, they cut and paste a character that isn't part of charset ISO-8859-1, such as a curly looking single
quote, etc.
Isn't actually get converted to html entities when the form is get
posted? Or is that a problem for you?
I did some searching, but couldn't find and php function that would filter this? Is there anything anyone has written, something like:

$string = convert_charset($string,ISO-8859-1);


Not sure <http://in.php.net/utf8_decode>
--
<?php echo 'Just another PHP saint'; ?>
Email: rrjanbiah-at-Y!com Blog: http://rajeshanbiah.blogspot.com/

Jul 17 '05 #3
Nope. In the Microsoft universe ISO-8859-1 = CP1252, so curly quotes
don't get escaped.

Jul 17 '05 #4

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

Similar topics

6
by: Markus Zeindl | last post by:
Hello, I want to write a simple encrypter, but I've got a problem: How can I convert characters into integers? I have got a string from the user, for example "Hi!". Now I get every character...
7
by: Nimmy | last post by:
Hi, I have a file which has different dates, I want to scanf them as CHAR and convert them to DATE format, how can I do this? Thanks
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 ,...
4
by: Paw Pedersen | last post by:
When using Encoding.Convert to convert from UTF-8 to ISO646-US the special Chars like ÆØÅ are replaced with a questionmark (?). Is there any other way to convert between encodings where you can set...
1
by: dotNeter | last post by:
I have a file with non-ISO extended-ASCII format, but my program only reads ISO ascii characters. How to do? thx
4
by: kettle | last post by:
Hi, I am rather new to python, and am currently struggling with some encoding issues. I have some utf-8-encoded text which I need to encode as iso-2022-jp before sending it out to the world. I am...
1
code green
by: code green | last post by:
I filter XML files through PHP for validation before passing to a SQL Server based program. This of the shelf program can only handle ASCII characters and not the extended ISO-8869 character set. ...
2
by: Andrea Robinson | last post by:
I need to convert data that is input from a file from ASCII chars to Ints, but the catch is no atoi and I can ONLY convert number characters and ignore the others, and the # symbol has to act like a...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.