/*--------------------------------------------------------------------------------------------- * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*//** * The normalize() method returns the Unicode Normalization Form of a given string. The form will be * the Normalization Form Canonical Composition. * * @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/normalize} */exportconstcanNormalize=typeof((<any>'').normalize)==='function';exportfunctionnormalizeNFC(str:string):string{returnnormalize(str,'NFC');}exportfunctionnormalizeNFD(str:string):string{returnnormalize(str,'NFD');}constnonAsciiCharactersPattern=/[^\u0000-\u0080]/;functionnormalize(str:string,form:string):string{if(!canNormalize||!str){returnstr;}letres:string;if(nonAsciiCharactersPattern.test(str)){res=(<any>str).normalize(form);}else{res=str;}returnres;}