html设置input输入字符编码是,处理html输入标记中的utf8编码字符(dealing with utf8 encoded characters in html input tag)...

处理html输入标记中的utf8编码字符(dealing with utf8 encoded characters in html input tag)

我正在动态添加输入标记的值。 值从服务器返回,在某些情况下,它们是UTF8编码的。 长话短说,输入标签的值仍保留编码字符,例如Sábado给用户。

在我的span标签中,值根据需要呈现,这意味着输出'Sábado'。 我确实用过

我怎样才能解决这个问题?

谢谢。

I'm dynamically adding value of an input tag. The values are returned from the server, and at some cases they are UTF8 encoded. Long story, short, the value of input tags still keeps the encoded characters, rendering e.g. Sábado to the user.

In my span tags, the value is rendered as desired, meaning that 'Sábado' is outputted. I do use

How can I fix this?

thanks.

原文:https://stackoverflow.com/questions/10007026

更新时间:2020-02-20 13:53

最满意答案

这些字符串不是“UTF8编码”,它们是HTML实体 。

不要HTML转义值。 可能你在某个地方双重逃离它们。

如果没有关于代码的详细信息,很难给出更具体的建议。

Those strings are not "UTF8 encoded", those are HTML entities.

Don't HTML escape the values. Possibly you're double-escaping them somewhere.

Hard to give more concrete advise without details about your code.

相关问答

转储文件可能输出为UTF-8,但在导入期间解释为latin1。 ë ,UTF-8的latin1双字节表示,在您的表中作为UTF-8数据。 看到你有完整和破碎数据的混合,这将很难以一般方式修复,但通常,这个肮脏的解决方法*将很好地工作: UPDATE table SET column = REPLACE("ë", "ë", column);

除非您使用的语言不是荷兰语,否则破碎字符的范围应该非常有限,您可以使用少量此类语句来修复它。 有相同问题的相关问题: 检测MySQL中的utf8中断字符

...

作为解决方法使用htmlDocContentDumpOutput()函数。 将文档内容转储到char缓冲区并将缓冲区写入文件。 //htmlSaveFileEnc("modified.html", docPtr, "utf8");

xmlOutputBufferPtr out = xmlAllocOutputBuffer(NULL);

if (out) {

htmlDocContentDumpOutput(out, docPtr, "utf8");

const xmlChar *buffe

...

我不相信这是编码的问题。 您所看到的是未转义的XML字符串。 问题是" 是一个XML转义字符,因此XMLTextReader将为您取消转义。 如果你改变了这个: Example "content" And ─

对此: Example "content" And ─

然后 XmlReader.Value

...

数据在MySQL中存储为UTF-8,但PHP的客户端连接排序规则不是。 这就是为什么你必须在PHP中使用set_charset进行数据库连接。 更新 php.ini :default_charset utf-8 .htaccess :AddDefaultCharset utf-8 The data is stored as UTF-8 in MySQL, but the PHP's client connection collation is not. Which is why you have

...

虽然我不确定如何使用->loadHTMLFile()解决问题,您是否考虑过使用file_get_contents()来获取HTML,对该字符串运行mb_convert_encoding() ,然后将该值传递给->loadHTML() ? 编辑:此外,当你初始化DOMDocument ,你给它的$编码参数? While I'm not sure about how to go about solving the problem with ->loadHTMLFile(), have you cons

...

从JsonConvert.SerializeObject获取输出并通过一个帮助器方法运行它,该方法将所有非ASCII字符转换为它们的转义(“\ uHHHH”)等效字符。 下面给出了一个示例实现。 // Replaces non-ASCII with escape sequences;

// i.e., converts "Tulgôr" to "Tulg\u00f4r".

private static string EscapeUnicode(string input)

{

StringB

...

查看实际存储内容的一种方法是使用HEX功能。 (这是最接近Oracle风格的DUMP()函数的MySQL。 这是一个演示,显示使用HEX函数返回存储的内容...... CREATE TABLE foo

( foo_lat VARCHAR(10) CHARSET latin1

, foo_utf VARCHAR(10) CHARSET utf8

);

INSERT INTO foo (foo_lat, foo_utf) VALUES

( UNHEX('6dc3b1c3b6

...

这些字符串不是“UTF8编码”,它们是HTML实体 。 不要HTML转义值。 可能你在某个地方双重逃离它们。 如果没有关于代码的详细信息,很难给出更具体的建议。 Those strings are not "UTF8 encoded", those are HTML entities. Don't HTML escape the values. Possibly you're double-escaping them somewhere. Hard to give more concrete ad

...

如果您使用的是MySQL,请在DB连接后使用以下内容 mysql_query(“SET NAMES utf8”); 如果您使用的是MySQLi,请在DB连接后使用以下内容 mysqli_set_charset($connection,"utf8");

如果您正在使用mysqli的类和对象,请在下面使用 $mysqli = new mysqli("localhost", "root", "", "test");

$mysqli->set_charset("utf8");

希望这会有所帮助! If

...

我不认为这是允许的: ID和名称标记必须以字母([A-Za-z])开头,后面可以跟随任意数量的字母,数字([0-9]),连字符(“ - ”),下划线(“_”) ,冒号(“:”)和句点(“。”)。 http://www.w3.org/TR/html401/types.html#type-name I don't think this is allowed: ID and NAME tokens must begin with a letter ([A-Za-z]) and may be follow

...

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Apps are at the heart of Windows 8, bringing rich and engaging experiences to both tablet and desktop users. Windows 8 uses the Windows Runtime (WinRT), a complete reimagining of Windows development that supports multiple programming languages and is built on HTML5, CSS and JavaScript. These applications are the future of Windows development and JavaScript is perfect language to take advantage of this exciting and flexible environment. Seasoned author Adam Freeman explains how to get the most from WinRT and Windows 8 by focusing on the features you need for your project. He starts with the nuts-and-bolts and shows you everything through to advanced features, going in-depth to give you the knowledge you need. Each topic is covered clearly and concisely and is packed with the details you need to learn to be truly effective. The most important features are given a no-nonsense in-depth treatment and chapters contain examples that demonstrate both the power and the subtlety of Windows 8, Windows Runtime and Javascript. What you’ll learn Understand what Windows 8 apps and WinRT are capable of and why they are special Use advanced features to create immersive and engaging Windows 8 applications Creating applications that work seamlessly on tablets and desktops Use cutting-edge features like WebSockets and Cloud Computing Prepare and deploy your applications Unit test, debug and performance-tune applications Who this book is for This book is suitable for anyone wanting to get to grips with Windows 8 development using the cross-platform standards of HTML5 and JavaScript. Basic coding knowledge is assumed but no Microsoft-specific assumptions are made. Table of Contents Part I – Getting Started 1. Putting Windows 8 and WinRT in Context 2. Preparing for Development 3. HTML5 Primer 4. CSS3 Primer 5. JavaScript Language Primer Part II – Core App Development 6. A First Application 7. Creating the Main UI 8. Creating the Start Menu UI 9. Handling Touch Events 10. Dealing with I/O and Storage 11. Using Networking and the Cloud 12. Asynchronous Programming 13. Using Data & Databases 14. Windows 8 Platform Integration 15. Using Geolocation 16. Working with Multimedia Part III – Packaging & Deployment 17. Preparing for Deployment 18. Dealing with licences, signing and the Windows store 19. Using side-loading and Enterprise deployments 20. Managing versions and telemetry Part IV – Advanced Metro Development 21. Sharing Data 22. Developing with multiple programming languages 23. Performance Tuning Applications 24. Unit Testing JavaScript Applications 25. Security & Cryptography 26. Internationalization

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值