sqlite 简单手记

delete from TableName;  //清空数据 
update sqlite_sequence SET seq = 0 where name ='TableName';//自增长ID为0
更新删除时,如何插入有单引号(')的字符串,将所有单引号替换为两个单引号

sql = sql.Replace("'","''");

保存到SQLite数据库中时自动恢复为单引号,也就是说使用双单引号即可,例如:
INSERT INTO TableName VALUES('James''s Street');
插入数据库的是: James's Street 。

sqlite数据库在搜索的时候,一些特殊的字符需要进行转义, 具体的转义如下: 
     /   ->    //
     ‘   ->    ”
     [   ->    /[
     ]   ->    /]
     %   ->    /%
     &   ->    /&
        ->    /
     (   ->    /(
     )   ->    /)

JS中转义字符在replace中的转码替换

JS特殊符号的replace转码替换方法.

里面转的不全, 比如& 很多没有加, 自己添加把.

关于转义字符先关的网址:

 

<script>
        window.onload = function () {
            var xxxx = "&quot;&lt;&gt;&amp;测试代码";
            alert(html_decode(xxxx));
        }

function html_encode(str)   
{   
  var s = "";   
  if (str.length == 0) return "";   
  s = str.replace(/&/g, "&gt;");   
  s = s.replace(/</g, "&lt;");   
  s = s.replace(/>/g, "&gt;");   
  s = s.replace(/ /g, "&nbsp;");   
  s = s.replace(/\'/g, "&#39;");   
  s = s.replace(/\"/g, "&quot;");   
  s = s.replace(/\n/g, "<br>");   
  return s;   
}   

function html_decode(str)   
{   
  var s = "";   
  if (str.length == 0) return "";   
  s = str.replace(/&gt;/g, "&");   
  s = s.replace(/&lt;/g, "<");   
  s = s.replace(/&gt;/g, ">");   
  s = s.replace(/&nbsp;/g, " ");   
  s = s.replace(/&#39;/g, "\'");   
  s = s.replace(/&quot;/g, "\"");   
  s = s.replace(/<br>/g, "\n");   
  return s;   
}   

</script>

 

 

HTML特殊转义字符对照表

字符 十进制 转义字符
&#34; &quot;
& &#38; &amp;
< &#60; &lt;
> &#62; &gt;
不断开空格(non-breaking space) &#160; &nbsp;

 

HTML特殊转义字符对照表
字符 十进制 转义字符 字符 十进制 转义字符 字符 十进制 转义字符
? &#161; &iexcl; Á &#193; &Aacute; á &#225; &aacute;
&#162; &cent; Â &#194; &circ; â &#226 &acirc;
&#163; &pound; Ã &#195; &Atilde; ã &#227; &atilde;
¤ &#164; &curren; Ä &#196; &Auml ä &#228; &auml;
&#165; &yen; Å &#197; &ring; å &#229; &aring;
| &#166; &brvbar; Æ &#198; &AElig; æ &#230; &aelig;
§ &#167; &sect; Ç &#199; &Ccedil; ç &#231; &ccedil;
¨ &#168; &uml; È &#200; &Egrave; è &#232; &egrave;
© &#169; &copy; É &#201; &Eacute; é &#233; &eacute;
a &#170; &ordf; Ê &#202; &Ecirc; ê &#234; &ecirc;
? &#171; &laquo; Ë &#203; &Euml; ë &#235; &euml;
? &#172; &not; Ì &#204; &Igrave; ì &#236; &igrave;
/x7f &#173; &shy; Í &#205; &Iacute; í &#237; &iacute;
® &#174; &reg; Î &#206; &Icirc; î &#238; &icirc;
ˉ &#175; &macr; Ï &#207; &Iuml; ï &#239; &iuml;
° &#176; &deg; Ð &#208; &ETH; ð &#240; &ieth;
± &#177; &plusmn; Ñ &#209; &Ntilde; ñ &#241; &ntilde;
2 &#178; &sup2; Ò &#210; &Ograve; ò &#242; &ograve;
3 &#179; &sup3; Ó &#211; &Oacute; ó &#243; &oacute;
&#180; &acute; Ô &#212; &Ocirc; ô &#244; &ocirc;
μ &#181; &micro; Õ &#213; &Otilde; õ &#245; &otilde;
? &#182; &para; Ö &#214; &Ouml; ö &#246; &ouml;
· &#183; &middot; &times; &#215; &times; ÷ &#247; &divide;
? &#184; &cedil; Ø &#216; &Oslash; ø &#248; &oslash;
1 &#185; &sup1; Ù &#217; &Ugrave; ù &#249; &ugrave;
o &#186; &ordm; Ú &#218; &Uacute; ú &#250; &uacute;
? &#187; &raquo; Û &#219; &Ucirc; û &#251; &ucirc;
? &#188; &frac14; Ü &#220; &Uuml; ü &#252; &uuml;
? &#189; &frac12; Ý &#221; &Yacute; ý &#253; &yacute;
? &#190; &frac34; Þ &#222; &THORN; þ &#254; &thorn;
? &#191; &iquest; ß &#223; &szlig; ÿ &#255; &yuml;
À &#192; &Agrave; à &#224; &agrave;