Skip to content

Instantly share code, notes, and snippets.

@nexpr
Created February 18, 2016 15:43
Show Gist options
  • Select an option

  • Save nexpr/41d45a4f1b719648cf97 to your computer and use it in GitHub Desktop.

Select an option

Save nexpr/41d45a4f1b719648cf97 to your computer and use it in GitHub Desktop.
calc sarogate pair
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