mirror of
https://github.com/fofolee/uTools-Manuals.git
synced 2025-12-15 15:20:30 +08:00
语法高亮,滚动条美化,设置页面调整
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
<div><iframe class="interactive interactive-js" frameborder="0" height="250" src="https://interactive-examples.mdn.mozilla.net/pages/js/string-charcodeat.html" width="100%"></iframe></div>
|
||||
<p class="hidden">The source for this interactive example is stored in a GitHub repository. If you'd like to contribute to the interactive examples project, please clone <a class="external" href="https://github.com/mdn/interactive-examples" rel="noopener">https://github.com/mdn/interactive-examples</a> and send us a pull request.</p>
|
||||
<h2 id="语法">语法</h2>
|
||||
<pre class="syntaxbox"><code><em>str</em>.charCodeAt(<em>index</em>)</code></pre>
|
||||
<pre><code class="language-javascript"><code><em>str</em>.charCodeAt(<em>index</em>)</code></code></pre>
|
||||
<h3 id="参数">参数</h3>
|
||||
<dl>
|
||||
<dt><code>index</code></dt>
|
||||
@@ -20,17 +20,17 @@
|
||||
<h2 id="Examples" name="Examples">示例</h2>
|
||||
<h3 id="Example:_Using_charCodeAt" name="Example:_Using_charCodeAt">使用 <code>charCodeAt()</code></h3>
|
||||
<p>下例介绍了不同索引情况下返回的 Unicode 值:</p>
|
||||
<pre class="brush: js">"ABC".charCodeAt(0) // returns 65:"A"
|
||||
<pre><code class="language-javascript">"ABC".charCodeAt(0) // returns 65:"A"
|
||||
|
||||
"ABC".charCodeAt(1) // returns 66:"B"
|
||||
|
||||
"ABC".charCodeAt(2) // returns 67:"C"
|
||||
|
||||
"ABC".charCodeAt(3) // returns NaN</pre>
|
||||
"ABC".charCodeAt(3) // returns NaN</code></pre>
|
||||
<h3 id="使用_charCodeAt()_修复字符串中出现的未知的非基本多语言范围(非BMP,non-Basic-Multilingual-Plane)字符">使用 <code>charCodeAt()</code> 修复字符串中出现的未知的非基本多语言范围(非BMP,non-Basic-Multilingual-Plane)字符</h3>
|
||||
<p>这段代码可以被用在 for 循环和其他类似语句中,当在指定引索之前不确定是否有非BMP字符存在时。</p>
|
||||
<p> </p>
|
||||
<pre class="brush:js">function fixedCharCodeAt (str, idx) {
|
||||
<pre><code class="language-js">function fixedCharCodeAt (str, idx) {
|
||||
// ex. fixedCharCodeAt ('\uD800\uDC00', 0); // 65536
|
||||
// ex. fixedCharCodeAt ('\uD800\uDC00', 1); // false
|
||||
idx = idx || 0;
|
||||
@@ -57,9 +57,9 @@
|
||||
}
|
||||
return code;
|
||||
}
|
||||
</pre>
|
||||
</code></pre>
|
||||
<h3 id="使用_charCodeAt()_修复字符串中出现的已知的非BMP字符">使用 <code>charCodeAt()</code> 修复字符串中出现的已知的非BMP字符</h3>
|
||||
<pre class="brush:js">function knownCharCodeAt (str, idx) {
|
||||
<pre><code class="language-js">function knownCharCodeAt (str, idx) {
|
||||
str += '';
|
||||
var code,
|
||||
end = str.length;
|
||||
@@ -91,7 +91,7 @@
|
||||
return code;
|
||||
}
|
||||
|
||||
</pre>
|
||||
</code></pre>
|
||||
<h2 id="规范">规范</h2>
|
||||
<table class="standard-table">
|
||||
<tbody>
|
||||
|
||||
Reference in New Issue
Block a user