简体   繁体   中英

Replacing quotes but keeping UTF-8 characters unaltered

Short question you guys: I have a PHP string which may or maybe not contain quotes, but it surely contains UTF-8 characters like ă, î, ş, ţ or â. What I would like to do is escape those quotes (so I can display the string in a text input) but keep the characters unaltered (for example don't transform î in "& amp;amp;icirc;").

Thank you.

You're probably looking for htmlspecialchars , which targets only < , > , ampersands and single and/or double quotes, depending on both the provided character set and quote-escaping commands.

This is as opposed to htmlentities , which encodes everything . If your input is in UTF-8, and your output is also in UTF-8, you shouldn't need to encode any entities in your string.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM