Jump to content

Archived

This topic is now archived and is closed to further replies.

Darkness Soul

Replace Special Chars

Recommended Posts

Yo,

Guys, I need a little help.. or maybe a little function.. I've been seach at php.net function list and don't see nothing like what I need..

I need a function to remove and replace special chars.. to make safe names to the images without cripty then..
exemple:
[code]$image = '#_Àéçomn_01.jpg' ;

$image = fun_rem_spec_char ( $image ) ;

print $image ;[/code]
: _Aecomn_01.jpg

Thanks for the help..

D.Soul

Share this post


Link to post
Share on other sites
Will the incoming character set always be the same? (Do you know it?)

Share this post


Link to post
Share on other sites
Nops,

This is a "public private" tool.. a lot of users may upload a lot of images..

You think about convert the charset? or something like it?

D.Soul

Share this post


Link to post
Share on other sites
This is a bit of a challenge because you're trying to [i]visually[/i] (not [i]actually[/i]) convert a character set. To my knowledge there is nothing in PHP to do this because, honestly, you shouldn't. See my signature about Unicode and character sets; here's a quote from it: "There Ain't No Such Thing As Plain Text."

Why don't you convert the string to UTF-8 and use it as is? Are you running Unix?

For example:

[tt]<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<?php

$string = '#_Àéçomn_01.jpg';
echo utf8_encode($string);

?>
</body>
</html>[/tt]

Share this post


Link to post
Share on other sites
I ran across [url=http://us2.php.net/manual/en/function.mb-convert-encoding.php#69412]this[/url]; "some code to convert latin diacritics to their traditional 7bit representation."

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.