static void MakeDepFileName(ResChar (&destination)[DestCount], const ResChar baseDirectory[], const ResChar depFileName[]) { // if the prefix of "baseDirectory" and "intermediateFileName" match, we should skip over that const ResChar* f = depFileName, *b = baseDirectory; while (ConvChar(*f) == ConvChar(*b) && *f != '\0') { ++f; ++b; } while (ConvChar(*f) == '/') { ++f; } _snprintf_s(destination, sizeof(ResChar)*DestCount, _TRUNCATE, "%s/.deps/%s", baseDirectory, f); }
//--------------------------------------------------------------------------- int __fastcall CMBCS::ConvAlpha(int code) { switch(m_Charset){ case SHIFTJIS_CHARSET: // JA if( (code >= 0x8140) && (code <= 0x81ff) ){ code = ConvChar(_tConvAlphaJA, code); } else if( (code >= 0x824f) && (code <= 0x8258) ){ code -= (0x824f - 0x30); } else if( (code >= 0x8260) && (code <= 0x8279) ){ code -= (0x8260 - 0x41); } else if( (code >= 0x8281) && (code <= 0x829a) ){ code -= (0x8281 - 0x61); } break; case HANGEUL_CHARSET: // HL case 134: // BY if( code == 0xa1a1 ){ code = 0x20; } else if( (code >= 0xa3a1) && (code <= 0xa3ff) ){ int c = code - (0xa3a1 - 0x21); if( !strchr(_tInhibit, c) ) code = c; } break; case CHINESEBIG5_CHARSET: // BV if( (code >= 0xa140) && (code <= 0xa249) ){ code = ConvChar(_tConvAlphaBV, code); } else if( (code >= 0xa2af) && (code <= 0xa2b9) ){ code -= (0xa2af - 0x30); } else if( (code >= 0xa2cf) && (code <= 0xa2e8) ){ code -= (0xa2cf - 0x41); } else if( (code >= 0xa2e9) && (code <= 0xa2fe) ){ code -= (0xa2cf - 0x61); } else if( (code >= 0xa340) && (code <= 0xa343) ){ code -= (0xa340 - 'w'); } break; default: break; } return code; }
std::string HtmlStrDecode(const std::string& htmlStr, const char* encTo, bool decodeChar){ if(htmlStr.empty() || encTo == NULL) return ""; std::string destStr = htmlStr; std::string tmpStr = destStr; boost::smatch what; // dec unicode convert 年 boost::regex unicodeDecReg("&#\\d{1,6};"); std::string::const_iterator start = tmpStr.begin(); std::string::const_iterator end = tmpStr.end(); while ( boost::regex_search(start, end, what, unicodeDecReg) ) { // split unicode number std::string unicode(what[0].str(), 2, what[0].str().size() - 3); // convert unicode to char std::string dest = ConvChar(atoi(unicode.c_str()), encTo, "UTF-16"); // find next unicode number start = what[0].second; // replace html unicode to char boost::replace_all(destStr, what[0].str(), dest); } // standard unicode convert \u5e74 boost::regex unicodeReg("\\\\u\\w{1,4}"); tmpStr = destStr; start = tmpStr.begin(); end = tmpStr.end(); while ( boost::regex_search(start, end, what, unicodeReg) ) { std::string str(what[0].str(), 2, what[0].str().size() - 2); uint32_t unicode = hex_to_decimal(str.c_str(), str.size()); std::string dest = ConvChar(unicode, encTo, "UTF-16"); boost::replace_all(destStr, what[0].str(), dest); start = what[0].second; } // Hex unicode convert 年 boost::regex unicodeHexReg("&#x\\w{1,4}"); tmpStr = destStr; start = tmpStr.begin(); end = tmpStr.end(); while ( boost::regex_search(start, end, what, unicodeHexReg) ) { // split unicode number std::string str(what[0].str(), 3, what[0].str().size() - 3); uint32_t unicode = hex_to_decimal(str.c_str(), str.size()); std::string dest = ConvChar(unicode, encTo, "UTF-16"); boost::replace_all(destStr, what[0].str(), dest); start = what[0].second; } // special char convert boost::regex spCharReg("&[A-Za-z0-9]{2,8};"); tmpStr = destStr; start = tmpStr.begin(); end = tmpStr.end(); while ( boost::regex_search(start, end, what, spCharReg) ) { std::string spstr(what[0].str(), 1, what[0].str().size() - 2); std::map<std::string, uint32_t>::const_iterator it = HtmlSpMap.find(spstr); if(HtmlSpMap.end() != it){ std::string dest = ConvChar(it->second, encTo, "UTF-16"); boost::replace_all(destStr, what[0].str(), dest); } start = what[0].second; } return destStr; }