svnno****@sourc*****
svnno****@sourc*****
2007年 9月 8日 (土) 00:12:41 JST
Revision: 217 http://svn.sourceforge.jp/cgi-bin/viewcvs.cgi?root=bbs2ch&view=rev&rev=217 Author: flyson Date: 2007-09-08 00:12:41 +0900 (Sat, 08 Sep 2007) Log Message: ----------- 文字実態参照を持たない文字を数値参照化 Modified Paths: -------------- trunk/bbs2chreader/chrome/content/bbs2chreader/post.js -------------- next part -------------- Modified: trunk/bbs2chreader/chrome/content/bbs2chreader/post.js =================================================================== --- trunk/bbs2chreader/chrome/content/bbs2chreader/post.js 2007-09-06 13:14:39 UTC (rev 216) +++ trunk/bbs2chreader/chrome/content/bbs2chreader/post.js 2007-09-07 15:12:41 UTC (rev 217) @@ -250,15 +250,32 @@ .getService(Components.interfaces.nsITextToSubURI); aString = entityConverter.ConvertToEntities(aString, - Components.interfaces.nsIEntityConverter.entityW3C); + Components.interfaces.nsIEntityConverter.html40); + var charset = ""; switch(this.type){ case this._bbs2chService.BOARD_TYPE_2CH: - return textToSubURI.ConvertAndEscape("Shift_JIS", aString); + charset = "Shift_JIS"; + break; case this._bbs2chService.BOARD_TYPE_BE2CH: - return textToSubURI.ConvertAndEscape("EUC-JP", aString); + charset = "EUC-JP"; + break; } - return aString; + if(charset){ + var escapedStr = textToSubURI.ConvertAndEscape(charset, aString); + var unescapedStr = textToSubURI.UnEscapeAndConvert(charset, escapedStr); + + if(aString != unescapedStr){ + var charactor = []; + for(var i = 0; i<aString.length; i++){ + var c = (aString[i] == unescapedStr[i]) ? aString[i] : ("&#" + aString.charCodeAt(i) + ";"); + charactor.push(c); + } + escapedStr = textToSubURI.ConvertAndEscape(charset, charactor.join("")); + } + return escapedStr; + } + return aString; }, post: function(aListener){ this.listener = aListener;