SJIS-to-JIS conversion algorithm

iroiro

後輩
Joined
8 Feb 2008
Messages
1
Reaction score
0
Please, if anyone knows i do need a SJIS-to-JIS conversion algorithm like JIS-to-SJIS one, published on en.wikipedia.org/wiki/Shift_JIS - i need it vice versa. thanks in advance for any help.
 
I hope I'm not doing your homework for you. Here's what I came up with, but not sure if I'm right. Please check it to make sure:

a = 1 if 64<=s2<=158, 0 otherwise
129<=s1<=159 => j1 = (s1 - 112) * 2 - a
224<=s1<=239 => j1 = (s1 - 176) * 2 - a

64<=s2<=158 => j2 = s2 - 31 - {1 if s2 >= 128, 0 otherwise}
159<=s2<=252 => j2 = s2 - 126
 
SJIStoJIS
//---- SJIS窶「ツカナスナ。窶堙ーJIS窶「ツカナスナ。窶堙俄?「テ焦?ツキ窶堋キ窶堙ゥナ?テ鳴絶?
inline void SJIStoJIS( u_char& knj1, u_char& knj2 )
{
knj1 <<= 1;
if( knj2 < 0x9F ){
if( knj1 < 0x3F ) knj1 += 0x1F; else knj1 -= 0x61;
if( knj2 > 0x7E ) knj2 -= 0x20; else knj2 -= 0x1F;
}else{
if( knj1 < 0x3F ) knj1 += 0x20; else knj1 -= 0x60;
knj2 -= 0x7E;
}
}
 
Back
Top Bottom