Jump to content


Photo

Replace Special Chars


  • Please log in to reply
4 replies to this topic

#1 Darkness Soul

Darkness Soul
  • Members
  • PipPipPip
  • Advanced Member
  • 133 posts
  • LocationBrazil; São Paulo.

Posted 12 July 2006 - 06:56 PM

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:
$image = '#_Àéçomn_01.jpg' ;

$image = fun_rem_spec_char ( $image ) ;

print $image ;
: _Aecomn_01.jpg

Thanks for the help..

D.Soul
(If something is wrong, please tell me. I'm learning this language. Thank you)

#2 effigy

effigy
  • Staff Alumni
  • Advanced Member
  • 3,600 posts
  • LocationIL

Posted 12 July 2006 - 07:17 PM

Will the incoming character set always be the same? (Do you know it?)
Regexp | Unicode Article | Letter Database
/\A(e)?((1)?ff(?:(?:ig)?y)?|f(?:ig)?)\z/

#3 Darkness Soul

Darkness Soul
  • Members
  • PipPipPip
  • Advanced Member
  • 133 posts
  • LocationBrazil; São Paulo.

Posted 12 July 2006 - 07:33 PM

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
(If something is wrong, please tell me. I'm learning this language. Thank you)

#4 effigy

effigy
  • Staff Alumni
  • Advanced Member
  • 3,600 posts
  • LocationIL

Posted 12 July 2006 - 07:59 PM

This is a bit of a challenge because you're trying to visually (not actually) 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:

<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>

Regexp | Unicode Article | Letter Database
/\A(e)?((1)?ff(?:(?:ig)?y)?|f(?:ig)?)\z/

#5 effigy

effigy
  • Staff Alumni
  • Advanced Member
  • 3,600 posts
  • LocationIL

Posted 05 October 2006 - 05:16 PM

I ran across this; "some code to convert latin diacritics to their traditional 7bit representation."
Regexp | Unicode Article | Letter Database
/\A(e)?((1)?ff(?:(?:ig)?y)?|f(?:ig)?)\z/




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users