jQuery的解析统一characthers

jQuery的解析统一characthers

问题描述:

我有一个字符串,它基本上是这样的:jQuery的解析统一characthers

20 pcs 1/4" d 13/32" l shank copper round head solid rivets fasteners 

或:

20 Pcs 1/4" D 13/32" L Shank Copper Round Head Solid Rivets Fasteners 

凡"应表示为:“characther ...

在我的JS方法中,我将标签值设置为以下内容:

function WriteTitle(sentTitle){ 
$("#myTitle").text(sentTitle); 
} 

我一直在使用像decodeURIComponent,UNESCAPE或类似的方法来分析这些characthers尝试,但至今没有运气...

我如何分析这些进入正常角色?

+0

这可能是一个重复:https://*.com/questions/7885096/how-do-i-decode-a-string-with-escaped-unicode – Nick

这些不是unicode字符,而是HTML entities。你应该使用.html()方法,它不会逃脱它们(这正是.text()所做的)。

function WriteTitle(sentTitle){ 
    $("#myTitle").html(sentTitle); 
} 
+0

耶这是它!太多了! – User987

+0

@ User987不客气。不要忘记接受我的答案。 – Styx