Re: [fp-dev] [PATCH] proper use of htmlentities
Moved to GitHub: https://github.com/flatpressblog/flatpress
Brought to you by:
real_nowhereman
|
From: Naoki H. <n...@h7...> - 2006-11-17 19:50:58
|
NoWhereMan wrote:
> I've been thinking about this issue today. As we finally are supporting
> utf-8 (I would like to just not to support the others...), would
Absolutely. What on earth can be wrong with UTF-8 unless you want to
discriminate many of languages?
I think I really like you to officially decide not to support anything
but UTF-8 in order to make many people's life tremendously easier ;-)
> wp_specialchars() work better? you can find it in
> fp-includes/core/core.wp-formatting.php
> I guess it would be even better than the PHP original, as it should do less
> checks. What do you think?
Ah, I didn't realize this function. Yes, this works better. But I have
a question. What is the below for?
$text = preg_replace('/&([^#])(?![a-z12]{1,8};)/', '&$1', $text);
Come to think of it, I think we don't have to worry about anything but 5
characters in UTF-8 world and 1 character in FP world as below:
$text = str_replace('|', '|', $text); // just for FP format
$text = str_replace('&', '&', $text);
$text = str_replace('<', '<', $text);
$text = str_replace('>', '>', $text);
if ($quotes) {
$text = str_replace('"', '"', $text);
$text = str_replace("'", ''', $text);
}
All of other characters can be simply represented directly in UTF-8.
>>> By the way, I found that many of files are pretty mess with CRLF and
>>> LF. I am not sure what you are using (probably Windows, eh?) and
>>> how this
>>> mess happened. Having LF lines and CRLF lines in a file is little
>>> bothersome :-(
>
> The reason for this mess is an horrible horrible editor on Windows (which
> once I used to love, SciTE) which was supposed to handle correctly line
> ends.
I was using xemacs when I used to work on Windows :-)
I have switched to OSX about a month ago and I am free from those
Windows crap.... NOT :-( Occasionally I need to run Windows in
Parallels and deal with it.
> but that in fact it doesn't :/ Usually I work on Linux, but ATM I'm working
> with Windows... thank you for the per oneliner. I've got cygwin here, so I
> gave a a dos2unix on all of them. I didn't think about xargs... sometimes I
> just forget the basics :D
Another oneliner I would like to suggest is:
$ find . \( -name "*.php" -o -name "*.tpl" \) | xargs perl -pi -e
's/<form /<form accept-charset="utf-8" /'
Thanks,
-- Hiroshima
|