Created
February 18, 2016 15:43
-
-
Save nexpr/41d45a4f1b719648cf97 to your computer and use it in GitHub Desktop.
calc sarogate pair
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
| function sarope(x, y){ | |
| if(arguments.length === 1){ | |
| var u = x - 0x10000 | |
| var upper = ~~(u / 0x400) + 0xd800 | |
| var lower = ~~(u % 0x400) + 0xdc00 | |
| return {upper, lower} | |
| }else if(arguments.length === 2){ | |
| return 0x10000 + (x - 0xd800) * 0x400 + (y - 0xdc00) | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment