Last active
December 25, 2015 03:59
-
-
Save zfkun/6913546 to your computer and use it in GitHub Desktop.
JavaScript implements for `ascii2native`
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* javascript implements for `ascii2native` | |
* | |
* @file ascii2native | |
* @author zfkun([email protected]) | |
*/ | |
/** | |
* pattern 1 | |
* | |
* @param {string} str | |
* @return {string} | |
*/ | |
function ascii2native( str ) { | |
return unescape( ( str + '' ).replace( /\\(?=u[\da-z]{4})/gi, '%' ) ); | |
} | |
/** | |
* pattern 2 | |
* | |
* @param {string} str | |
* @return {string} | |
*/ | |
/* | |
function ascii2native( str ) { | |
return ( str + '' ).replace( /\\u[\da-z]{4}/gi , function( ascii ) { | |
return unescape( ascii.replace( /\\/, '%' ) ); | |
}); | |
} | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment