Skip to content

Commit

Permalink
Merge 52e83a3 into 7d69bcc
Browse files Browse the repository at this point in the history
  • Loading branch information
k-takata authored Mar 10, 2021
2 parents 7d69bcc + 52e83a3 commit e3904ce
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 12 deletions.
6 changes: 3 additions & 3 deletions sakura_core/charset/CEuc.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,9 @@ inline int CEuc::_EucjpToUni_char( const unsigned char* pSrc, unsigned short* pD
czenkaku[0] = (pSrc[0] & 0x7f);
czenkaku[1] = (pSrc[1] & 0x7f);
// JIS → SJIS
ctemp = _mbcjistojms( (static_cast<unsigned int>(czenkaku[0]) << 8) | czenkaku[1] );
ctemp = _mbcjistojms_j( (static_cast<unsigned int>(czenkaku[0]) << 8) | czenkaku[1] );
if( ctemp != 0 ){
// NEC選定IBM拡張コードポイントををIBM拡張コードポイントにに変換
// NEC選定IBM拡張コードポイントをIBM拡張コードポイントに変換
unsigned int ctemp_ = SjisFilter_nec2ibm( ctemp );
ctemp = ctemp_;
// SJIS → Unicode
Expand Down Expand Up @@ -160,7 +160,7 @@ inline int CEuc::_UniToEucjp_char( const unsigned short* pSrc, unsigned char* pD
// SJIS -> JIS
unsigned int ctemp_ = SjisFilter_ibm2nec( (static_cast<unsigned int>(cbuf[0]) << 8) | cbuf[1] );
// < IBM拡張文字をNEC選定IBM拡張文字に変換
ctemp = _mbcjmstojis( ctemp_ );
ctemp = _mbcjmstojis_j( ctemp_ );
if( ctemp == 0 ){
berror = true;
pDst[0] = '?';
Expand Down
10 changes: 5 additions & 5 deletions sakura_core/charset/CJis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ const char* CJis::TABLE_JISESCDATA[] = {
#endif

/*!
JIS の一ブロック(エスケープシーケンスとエスケープシーケンスの間の区間)を変換
JIS の一ブロック(エスケープシーケンスとエスケープシーケンスの間の区間)を変換
eMyJisesc は、MYJISESC_HANKATA か MYJISESC_ZENKAKU。
*/
Expand Down Expand Up @@ -131,7 +131,7 @@ int CJis::_JisToUni_block( const unsigned char* pSrc, const int nSrcLen, unsigne
for( ; pr < pSrc+nSrcLen-1; pr += 2 ){
if( IsJisZen(reinterpret_cast<const char*>(pr)) ){
// JIS -> SJIS
ctemp = _mbcjistojms( (static_cast<unsigned int>(pr[0]) << 8) | pr[1] );
ctemp = _mbcjistojms_j( (static_cast<unsigned int>(pr[0]) << 8) | pr[1] );
if( ctemp != 0 ){
// 変換に成功。
// SJIS → Unicode
Expand Down Expand Up @@ -328,7 +328,7 @@ int CJis::_SjisToJis_char( const unsigned char* pSrc, unsigned char* pDst, EChar
// JIS -> SJIS
ctemp_ = SjisFilter_basis( static_cast<unsigned int>(pSrc[0] << 8) | pSrc[1] );
ctemp_ = SjisFilter_ibm2nec( ctemp_ );
ctemp = _mbcjmstojis( ctemp_ );
ctemp = _mbcjmstojis_j( ctemp_ );
if( ctemp != 0 ){
// 変換に成功。
pDst[0] = static_cast<char>( (ctemp & 0x0000ff00) >> 8 );
Expand Down Expand Up @@ -498,8 +498,8 @@ EConvertResult CJis::UnicodeToHex(const wchar_t* cSrc, const int iSLen, WCHAR* p
CNativeW cCharBuffer;
EConvertResult res;
int i;
WCHAR* pd;
unsigned char* ps;
WCHAR* pd;
unsigned char* ps;

// 2008/6/21 Uchi
if (psStatusbar->m_bDispUniInJis) {
Expand Down
43 changes: 39 additions & 4 deletions sakura_core/charset/codeutil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,17 @@

Shift_JIS fa40~fc4b の範囲の文字は 8754~879a または ed40~eefc に
散在する文字に変換された後に,JISに変換されます.

@param pszSrc [in] 変換する文字列へのポインタ (Shift JIS)

@author すい
@date 2002.10.03 1文字のみ扱い,変換まで行うように変更 genta
*/
unsigned int _mbcjmstojis_ex( unsigned int nSrc, bool* pbNonroundtrip )
{
unsigned int tmpw; /* ← int が 16 bit 以上である事を期待しています。 */
bool bnonrt = false;

unsigned char c0 = static_cast<unsigned char>((nSrc & 0x0000ff00) >> 8);
unsigned char c1 = static_cast<unsigned char>(nSrc & 0x000000ff);

Expand Down Expand Up @@ -78,12 +78,47 @@ unsigned int _mbcjmstojis_ex( unsigned int nSrc, bool* pbNonroundtrip )
else if( tmpw <= 0xfbfc ) { tmpw -= 0x0d1c; } /* fb9c~fbfc → ee80~eee0 (蕫~髙) */
else{ tmpw -= 0x0d5f; } /* fc40~fc4b → eee1~eeec (髜~黑) */
}
return _mbcjmstojis( tmpw );
return _mbcjmstojis_j( tmpw );
}
return 0;
}
#endif

static _locale_t ja_locale = nullptr;

static void init_ja_locale()
{
if (ja_locale == nullptr) {
ja_locale = _create_locale(LC_ALL, "Japanese_Japan.932");
}
}

/*!
@brief 常に日本語ロケールを使うSJIS→JIS変換
SJISコードをJISに変換する.
@param c [in] 変換する文字 (Shift JIS)
*/
unsigned int _mbcjmstojis_j( unsigned int c )
{
init_ja_locale();
return _mbcjmstojis_l(c, ja_locale);
}

/*!
@brief 常に日本語ロケールを使うJIS→SJIS変換
JISコードをSJISに変換する.
@param c [in] 変換する文字 (JIS)
*/
unsigned int _mbcjistojms_j( unsigned int c )
{
init_ja_locale();
return _mbcjistojms_l(c, ja_locale);
}

/*
判別テーブル WinAPI 関数 WideCharToMultiByte の特殊な変換(相互変換できない変換)か
添え字の定義域:0x00 ~ 0x5f(=0x00ff - 0x00a0)
Expand Down
2 changes: 2 additions & 0 deletions sakura_core/charset/codeutil.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
// 2008.11.10 引数と戻り値の型を _mbcjmstojis に似せる
unsigned int _mbcjmstojis_ex( unsigned int );
#endif
unsigned int _mbcjmstojis_j( unsigned int );
unsigned int _mbcjistojms_j( unsigned int );

unsigned int __fastcall SjisFilter_basis( const unsigned int );
unsigned int __fastcall SjisFilter_ibm2nec( const unsigned int );
Expand Down

0 comments on commit e3904ce

Please sign in to comment.