将文本从Word复制到textarea [英] Copying text from Word to textarea

查看:381
本文介绍了将文本从Word复制到textarea的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一个众所周知的问题:将MS Word中的文本复制到textarea时,文本的字符在保存到数据库时会转换为奇怪的字符。



我是想知道如何解决这个问题?
$ b


  1. 包含表单的HTML文档的字符编码

  2. 保存方法以清理数据

  3. 检索数据后进行清理(显示前)
  4. 数据库配置(表格的字符编码) li>

我宁愿如果1.能够工作,但任何其他解决方案都可以。

解决方案:


  1. 保存表单的HTML文档的字符编码

这通常是 1 工作。如果它不起作用,您的应用程序被破坏或浏览器被破坏或剪贴板被破坏或MSWord被破坏。

在任何情况下,您都无法修复MSWord <而不是剪贴板,浏览器服务器端。



取而代之的是确保网站使用的编码可以处理与来自剪贴板的字符一起使用,并且在处理输入数据时向您的应用程序授予编码请求。


$ b

1 请参阅处理HTML和CSS中的字符编码工作原理。


A well-known problem: When copying text fro MS Word into a textarea, the text's characters get converted to strange characters when saving it to database.

I was wondering how I should solve this?

  1. Character encoding of the HTML document that holds the form
  2. A before save method to sanitize the data
  3. Sanitization after retrieving the data (before displaying)
  4. A database configuration (character encoding for table)

I would prefer if 1. worked, but any other solution will do.

解决方案

The solution:

  1. Character encoding of the HTML document that holds the form

This does normally 1 work. If it does not work, your applpication is broken or the browser is broken or the clipboard is broken or MSWord is broken.

In any case, you can not fix MSWord nor the Clipboard, nor the browser server-side.

Instead ensure that the encoding the website is using can deal with the characters from the clipboard, and honor the encoding requests into your application have when you process input data.

1 Please see Handling character encodings in HTML and CSS how it works.

这篇关于将文本从Word复制到textarea的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆