diff options
author | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:42:17 -0500 |
---|---|---|
committer | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:42:17 -0500 |
commit | da78a9e329e272dedb2400b79a3bdeebff387d47 (patch) | |
tree | e6ef8aa7c43556f55ddfe031a01cf0a8fa271bfe /files/ko/web/javascript/reference/global_objects/string/normalize | |
parent | 1109132f09d75da9a28b649c7677bb6ce07c40c0 (diff) | |
download | translated-content-da78a9e329e272dedb2400b79a3bdeebff387d47.tar.gz translated-content-da78a9e329e272dedb2400b79a3bdeebff387d47.tar.bz2 translated-content-da78a9e329e272dedb2400b79a3bdeebff387d47.zip |
initial commit
Diffstat (limited to 'files/ko/web/javascript/reference/global_objects/string/normalize')
-rw-r--r-- | files/ko/web/javascript/reference/global_objects/string/normalize/index.html | 163 |
1 files changed, 163 insertions, 0 deletions
diff --git a/files/ko/web/javascript/reference/global_objects/string/normalize/index.html b/files/ko/web/javascript/reference/global_objects/string/normalize/index.html new file mode 100644 index 0000000000..d44f9bec99 --- /dev/null +++ b/files/ko/web/javascript/reference/global_objects/string/normalize/index.html @@ -0,0 +1,163 @@ +--- +title: String.prototype.normalize() +slug: Web/JavaScript/Reference/Global_Objects/String/normalize +tags: + - ECMAScript 2015 + - JavaScript + - Method + - Prototype + - Reference + - String + - Unicode +translation_of: Web/JavaScript/Reference/Global_Objects/String/normalize +--- +<div>{{JSRef}}</div> + +<p><strong><code>normalize()</code></strong> 메서드는 주어진 문자열을 유니코드 정규화 방식(Unicode Normalization Form)에 따라 정규화된 형태로 반환합니다. 만약 주어진 값이 문자열이 아닐 경우에는 우선 문자열로 변환 후 정규화합니다.</p> + +<div>{{EmbedInteractiveExample("pages/js/string-normalize.html")}}</div> + + + +<h2 id="구문">구문</h2> + +<pre class="syntaxbox"><code><var>str</var>.normalize([<var>form</var>])</code></pre> + +<h3 id="매개변수">매개변수</h3> + +<dl> + <dt><code>form</code></dt> + <dd>유니코드 정규화 방식을 지정합니다. <code>"NFC"</code>, <code>"NFD"</code>, <code>"NFKC"</code>, <code>"NFKD"</code> 중 하나이며, 생략되거나 {{jsxref("undefined")}} 일 경우 <code>"NFC"</code>가 사용됩니다. + <ul> + <li><code>NFC</code> — 정규형 정준 결합(Normalization Form Canonical Composition).</li> + <li><code>NFD</code> — 정규형 정준 분해(Normalization Form Canonical Decomposition).</li> + <li><code>NFKC</code> — 정규형 호환성 결합(Normalization Form Compatibility Composition).</li> + <li><code>NFKD</code> — 정규형 호환성 분해(Normalization Form Compatibility Decomposition).</li> + </ul> + </dd> +</dl> + +<h3 id="반환_값">반환 값</h3> + +<p>주어진 문자열을 유니코드 정규화 방식에 따라 정규화된 문자열로 반환합니다.</p> + +<h3 id="예외">예외</h3> + +<dl> + <dt>{{jsxref("RangeError")}}</dt> + <dd><code>form</code>이 위에서 명시된 값 중 하나가 아닐 경우 {{jsxref("RangeError")}} 에러가 발생합니다.</dd> +</dl> + +<h2 id="설명">설명</h2> + +<p><code>normalize()</code> 메서드는 문자열을 유니코드 정규화 방식에 따라 정규화된 형태로 반환합니다. 문자열의 값 자체에는 영향을 주지 않습니다.</p> + +<h2 id="예제">예제</h2> + +<h3 id="normalize()_사용하기"><code>normalize()</code> 사용하기</h3> + +<pre class="brush: js">// 원본 문자열 + +// U+1E9B: LATIN SMALL LETTER LONG S WITH DOT ABOVE +// U+0323: COMBINING DOT BELOW +var str = '\u1E9B\u0323'; + + +// 정규형 정준 결합 (NFC) + +// U+1E9B: LATIN SMALL LETTER LONG S WITH DOT ABOVE +// U+0323: COMBINING DOT BELOW +str.normalize('NFC'); // '\u1E9B\u0323' +str.normalize(); // 위와 같은 결과 + + +// 정규형 정준 분해 (NFD) + +// U+017F: LATIN SMALL LETTER LONG S +// U+0323: COMBINING DOT BELOW +// U+0307: COMBINING DOT ABOVE +str.normalize('NFD'); // '\u017F\u0323\u0307' + + +// 정규형 호환성 결합 (NFKC) + +// U+1E69: LATIN SMALL LETTER S WITH DOT BELOW AND DOT ABOVE +str.normalize('NFKC'); // '\u1E69' + + +// 정규형 호환성 분해 (NFKD) + +// U+0073: LATIN SMALL LETTER S +// U+0323: COMBINING DOT BELOW +// U+0307: COMBINING DOT ABOVE +str.normalize('NFKD'); // '\u0073\u0323\u0307' +</pre> + +<h3 id="한글에_normalize()_사용하기">한글에 <code>normalize()</code> 사용하기</h3> + +<pre class="brush: js">// 결합된 한글 문자열 + +// U+D55C: 한(HANGUL SYLLABLE HAN) +// U+AE00: 글(HANGUL SYLLABLE GEUL) +var first = '\uD55C\uAE00'; + + +// 정규형 정준 분해 (NFD) +// 정준 분해 결과 초성, 중성, 종성의 자소분리가 일어납니다. +// 일부 브라우저에서는 결과값 '한글'이 자소분리된 상태로 보여질 수 있습니다. + +// U+1112: ᄒ(HANGUL CHOSEONG HIEUH) +// U+1161: ᅡ(HANGUL JUNGSEONG A) +// U+11AB: ᆫ(HANGUL JONGSEONG NIEUN) +// U+1100: ᄀ(HANGUL CHOSEONG KIYEOK) +// U+1173: ᅳ(HANGUL JUNGSEONG EU) +// U+11AF: ᆯ(HANGUL JONGSEONG RIEUL) +var second = first.normalize('NFD'); // '\u1112\u1161\u11AB\u1100\u1173\u11AF' + + +// 정규형 정준 결합 (NFC) +// 정준 결합 결과 자소분리 되었던 한글이 결합됩니다. + +// U+D55C: 한(HANGUL SYLLABLE HAN) +// U+AE00: 글(HANGUL SYLLABLE GEUL) +var third = second.normalize('NFC'); // '\uD55C\uAE00' + + +console.log(second === third); // 같은 글자처럼 보이지만 false를 출력합니다. +</pre> + +<h2 id="명세">명세</h2> + +<table class="standard-table"> + <tbody> + <tr> + <th scope="col">Specification</th> + <th scope="col">Status</th> + <th scope="col">Comment</th> + </tr> + <tr> + <td>{{SpecName('ES2015', '#sec-string.prototype.normalize', 'String.prototype.normalize')}}</td> + <td>{{Spec2('ES2015')}}</td> + <td>초기 정의.</td> + </tr> + <tr> + <td>{{SpecName('ESDraft', '#sec-string.prototype.normalize', 'String.prototype.normalize')}}</td> + <td>{{Spec2('ESDraft')}}</td> + <td> </td> + </tr> + </tbody> +</table> + +<h2 id="브라우저_호환성">브라우저 호환성</h2> + +<p class="hidden">The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> and send us a pull request.</p> + +<p>{{Compat("javascript.builtins.String.normalize")}}</p> + +<h2 id="같이_보기">같이 보기</h2> + +<ul> + <li><a href="http://www.unicode.org/reports/tr15/">Unicode Standard Annex #15, Unicode Normalization Forms</a></li> + <li><a href="http://en.wikipedia.org/wiki/Unicode_equivalence">Unicode equivalence</a></li> + <li><a href="https://ko.wikipedia.org/wiki/%EC%9C%A0%EB%8B%88%EC%BD%94%EB%93%9C_%EC%A0%95%EA%B7%9C%ED%99%94">유니코드 정규화</a></li> +</ul> |