Last active
January 20, 2019 16:39
-
-
Save takamame0205/4ec7c83fddcb5ee76b4df18bd4df6926 to your computer and use it in GitHub Desktop.
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
uint16_t sjis2jis( uint16_t charcode ) | |
{ | |
// シフトJISコードをJISコードに変換する | |
// charcode = シフトJISコード | |
// 戻り値:JISコード | |
uint8_t h, l; | |
h = charcode >> 8; | |
l = charcode & 0xff; | |
if ( h >= 0xe0 ) { | |
h -= 0x40; | |
} | |
if ( l >= 0x80 ) { | |
l--; | |
} | |
if ( l >= 0x9e ) { | |
h = ( h - 0x70 ) << 1; | |
l -= 0x7d; | |
} | |
else { | |
h = ( ( h - 0x70 ) << 1 ) - 1; | |
l -= 0x1f; | |
} | |
return h << 8 | l; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment