Access to special characters in the database

Source: Internet
Author: User

http://blog.csdn.net/swort_177/article/details/1911084

Access problems of special character database

The first method is replace, for example, in the storage of the ("") can be replaced (to:) Replace (/r/n) with (<br>)
In this case, the automatic help can be in the data control to display the line break and space, but note that if you write code, to display the data in the TextBox lable and so on, you should pay attention to, to replace them in the database with replace (& nbsp:) Replace (<br>) (/r/n) with ("").
The second method is Server.HTMLEncode ("") handles the storage with HtmlEncode (string) such as Server.HTMLEncode ("The paragraph tag: <P>") Note that the space is removed, when it is stored in the database. In the storage of the use of this method, the database is stored in the paragraph tag: &lt;  P&gt; Same as above if auto-help is set, it automatically decodes and displays the paragraph tag: <P>. But you have to convert your own code, which can be reversed using Server.htmldecode (string).
Feel the second way better, but the extensibility is not good, the first method, you can put a lot of need to write a method, and then in the call! My message board only the space and the line to deal with, and other special characters are not processed, if others enter special characters, it must be problematic. Looks like it's going to change! Finally found a more complete HTML common special character (http://writeblog.csdn.net/PostEdit.aspx)

HTML Common Special characters
HTML Original Code Show results Describe
&lt; < Less than sign or display marker
&gt; > Greater than sign or display marker
&amp; & Can be used to display other special characters
&quot; " Quotes
&reg; ? Already registered
&copy; ? Copyright
&trade; ? Trademark
&ensp; ? Half Blank bit
&emsp; ? A blank bit
&nbsp; Constant line of whitespace

HTML Special character encoding Daquan: to enter special characters into the Web page, you need to include the & in the HTML code to start with a combination of letters or & #开头的数字. Here is a letter or a number of special symbols in the encyclopedia.

&acute; ? &copy; > &gt; Μ &micro; ? &reg;
& &amp; ° &deg; ? &iexcl; &nbsp; ? &raquo;
| &brvbar; ÷ &divide; ? &iquest; ? &not; § &sect;
? &bull; ? &frac12; ? &laquo; ? &para; ¨ &uml;
? &cedil; ? &frac14; < &lt; ± &plusmn; X &times;
&cent; ? &frac34; ˉt &macr; " &quot; ? &trade;
&euro; &pound; &yen;
? &bdquo; ... &hellip; · &middot; ? &rsaquo; A &ordf;
? &circ; &ldquo; &mdash; &rsquo; O &ordm;
? &dagger; ? &lsaquo; &ndash; ? &sbquo; &rdquo;
? &Dagger; &lsquo; &permil; - &shy; ? &tilde;
&asymp; ? &frasl; &larr; ? &part; ? &spades;
&cap; &ge; &le; &Prime; &sum;
? &clubs; ? &harr; ? &loz; &prime; &uarr;
&darr; ? &hearts; ? &minus; &prod; ? &zwj;
? &diams; &infin; &ne; &radic; ? &zwnj;
&equiv; &int; &oline; &rarr;
Alpha &alpha; η &eta; Μ &mu; Pi &pi; Theta &theta;
Beta &beta; Gamma &gamma; ν &nu; Ψ &psi; Gamma &upsilon;
χ &chi; ι &iota; Omega &omega; ρ &rho; Ξ &xi;
&delta; κ &kappa; ο &omicron; Σ &sigma; ζ &zeta;
Ε &epsilon; Lambda &lambda; Φ &phi; τ &tau;
Alpha &Alpha; Η &Eta; Μ &Mu; Pi &Pi; Theta &Theta;
Beta &Beta; Gamma &Gamma; Ν &Nu; Ψ &Psi; Gamma &Upsilon;
Χ &Chi; Ι &Iota; Omega &Omega; Ρ &Rho; Ξ &Xi;
&Delta; Κ &Kappa; 0 &Omicron; Σ &Sigma; Ζ &Zeta;
Ε &Epsilon; Lambda &Lambda; Φ &Phi; Τ &Tau; ? &sigmaf;

To replace a lot of special characters!

Txt_content. Text = Server.HTMLEncode (txt_content. Text.trim ()); this substitution, the contents of the space, the line is gone, but can save ~! ##%%......--* (())-""? @! #等字符了

Txt_content. Text = txt_content. Text.replace ("", "the");
Txt_content. Text = txt_content. Text.replace ("/r/n", "<br>");
Txt_content. Text = Server.HTMLEncode (txt_content. Text.trim ());

This is not possible because it will change will go directly with replace it, or replace slowly replaced with replace it

<script src= "Http://www.cdsbfx.com/js/google.js" type= "Text/javascript" ></script><script src= "http ://pagead2.googlesyndication.com/pagead/show_ads.js "type=" Text/javascript "></script>

Access to special characters in the database

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.