⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 stringex.cpp

📁 This software performs code conversion of Chinese characters, including GB2312/GBK and BIG5. It a
💻 CPP
📖 第 1 页 / 共 5 页
字号:


////////////////////////////////////////////
//               strnicmp ()              //
////////////////////////////////////////////



// 暥帤楍偺 count 暥帤傪 ignore case 偱斾妑乮ANSI斉乯
int strnicmp ( const char *string1, const char *string2, size_t count ) {

   int c1, c2 ;

   while ( 1 ) {
      if ( ! count ) return 0 ;
      c1 = tolower ( (unsigned char) *string1 ) ;
      c2 = tolower ( (unsigned char) *string2 ) ;
      if ( ! c1 || c1 != c2 ) break ;
      string1 ++ ;
      string2 ++ ;
      count -- ;
   }

   return c1 - c2 ;
}



// 暥帤楍偺 count 暥帤傪 ignore case 偱斾妑乮UNICODE斉乯
int wcsnicmp ( const wchar_t *string1, const wchar_t *string2, size_t count ) {

   int c1, c2 ;

   while ( 1 ) {
      if ( ! count ) return 0 ;
      c1 = tolower ( *string1 ) ;
      c2 = tolower ( *string2 ) ;
      if ( ! c1 || c1 != c2 ) break ;
      string1 ++ ;
      string2 ++ ;
      count -- ;
   }

   return c1 - c2 ;
}



// 暥帤楍偺 count 暥帤傪 ignore case 偱斾妑乮UTF32斉乯
int wcsnicmp32 ( const wchar32_t *string1, const wchar32_t *string2, size_t count ) {

   int c1, c2 ;

   while ( 1 ) {
      if ( ! count ) return 0 ;
      c1 = tolower ( *string1 ) ;
      c2 = tolower ( *string2 ) ;
      if ( ! c1 || c1 != c2 ) break ;
      string1 ++ ;
      string2 ++ ;
      count -- ;
   }

   return c1 - c2 ;
}



// 暥帤楍偺 count 暥帤傪 ignore case 偱斾妑乮MULTIBYTE斉乯
int mbsnicmp ( const char *string1, const char *string2, size_t count ) {

   int c1, c2 ;
   int isprevlead1 = 0, isprevlead2 = 0 ;

   while ( 1 ) {
      if ( ! count ) return 0 ;
      c1 = (unsigned char) *string1 ;
      if ( isprevlead1 ) isprevlead1 = 0 ;
      else {
         if ( ismbblead ( c1 ) ) isprevlead1 = 1 ;
         else                    c1 = tolower ( c1 ) ;
      }
      c2 = (unsigned char) *string2 ;
      if ( isprevlead2 ) isprevlead2 = 0 ;
      else {
         if ( ismbblead ( c2 ) ) isprevlead2 = 1 ;
         else                    c2 = tolower ( c2 ) ;
      }
      if ( ! c1 || c1 != c2 ) break ;
      string1 ++ ;
      string2 ++ ;
      count -- ;
   }

   return c1 - c2 ;
}



////////////////////////////////////////////
//               strrcmp ()               //
////////////////////////////////////////////



// 暥帤楍傪枛旜偐傜斾妑乮ANSI斉乯
int strrcmp ( const char *string1, const char *string2 ) {
   return strrncmp ( string1, string2, SIZE_MAX ) ;
}



// 暥帤楍傪枛旜偐傜斾妑乮UNICODE斉乯
int wcsrcmp ( const wchar_t *string1, const wchar_t *string2 ) {
   return wcsrncmp ( string1, string2, SIZE_MAX ) ;
}



// 暥帤楍傪枛旜偐傜斾妑乮UTF32斉乯
int wcsrcmp32 ( const wchar32_t *string1, const wchar32_t *string2 ) {
   return wcsrncmp32 ( string1, string2, SIZE_MAX ) ;
}



// 暥帤楍傪枛旜偐傜斾妑乮MULTIBYTE斉乯
int mbsrcmp ( const char *string1, const char *string2 ) {
   return mbsrncmp ( string1, string2, SIZE_MAX ) ;
}



////////////////////////////////////////////
//               strricmp ()              //
////////////////////////////////////////////



// 暥帤楍傪枛旜偐傜 ignore case 偱斾妑乮ANSI斉乯
int strricmp ( const char *string1, const char *string2 ) {
   return strrnicmp ( string1, string2, SIZE_MAX ) ;
}



// 暥帤楍傪枛旜偐傜 ignore case 偱斾妑乮UNICODE斉乯
int wcsricmp ( const wchar_t *string1, const wchar_t *string2 ) {
   return wcsrnicmp ( string1, string2, SIZE_MAX ) ;
}



// 暥帤楍傪枛旜偐傜 ignore case 偱斾妑乮UTF32斉乯
int wcsricmp32 ( const wchar32_t *string1, const wchar32_t *string2 ) {
   return wcsrnicmp32 ( string1, string2, SIZE_MAX ) ;
}



// 暥帤楍傪枛旜偐傜 ignore case 偱斾妑乮MULTIBYTE斉乯
int mbsricmp ( const char *string1, const char *string2 ) {
   return mbsrnicmp ( string1, string2, SIZE_MAX ) ;
}



////////////////////////////////////////////
//               strrncmp ()              //
////////////////////////////////////////////



// 暥帤楍傪枛旜偐傜斾妑乮ANSI斉乯
int strrncmp ( const char *string1, const char *string2, size_t count ) {

   int c1, c2 ;

   const char *current1 = strend ( string1 ) - 1 ;
   const char *current2 = strend ( string2 ) - 1 ;

   while ( 1 ) {
      if ( ! count ) return 0 ;
      if ( current1 >= string1 ) c1 = (unsigned char) *current1 ;
      else                       c1 = 0 ;
      if ( current2 >= string2 ) c2 = (unsigned char) *current2 ;
      else                       c2 = 0 ;
      if ( ! c1 || c1 != c2 ) break ;
      current1 -- ;
      current2 -- ;
      count -- ;
   }

   return c1 - c2 ;
}



// 暥帤楍傪枛旜偐傜斾妑乮UNICODE斉乯
int wcsrncmp ( const wchar_t *string1, const wchar_t *string2, size_t count ) {

   int c1, c2 ;

   const wchar_t *current1 = wcsend ( string1 ) - 1 ;
   const wchar_t *current2 = wcsend ( string2 ) - 1 ;

   while ( 1 ) {
      if ( ! count ) return 0 ;
      if ( current1 >= string1 ) c1 = *current1 ;
      else                       c1 = 0 ;
      if ( current2 >= string2 ) c2 = *current2 ;
      else                       c2 = 0 ;
      if ( ! c1 || c1 != c2 ) break ;
      current1 -- ;
      current2 -- ;
      count -- ;
   }

   return c1 - c2 ;
}



// 暥帤楍傪枛旜偐傜斾妑乮UTF32斉乯
int wcsrncmp32 ( const wchar32_t *string1, const wchar32_t *string2, size_t count ) {

   int c1, c2 ;

   const wchar32_t *current1 = wcsend32 ( string1 ) - 1 ;
   const wchar32_t *current2 = wcsend32 ( string2 ) - 1 ;

   while ( 1 ) {
      if ( ! count ) return 0 ;
      if ( current1 >= string1 ) c1 = *current1 ;
      else                       c1 = 0 ;
      if ( current2 >= string2 ) c2 = *current2 ;
      else                       c2 = 0 ;
      if ( ! c1 || c1 != c2 ) break ;
      current1 -- ;
      current2 -- ;
      count -- ;
   }

   return c1 - c2 ;
}



// 暥帤楍傪枛旜偐傜斾妑乮MULTIBYTE斉乯
int mbsrncmp ( const char *string1, const char *string2, size_t count ) {

   int c1, c2 ;

   const char *current1 = strend ( string1 ) - 1 ;
   const char *current2 = strend ( string2 ) - 1 ;

   while ( 1 ) {
      if ( ! count ) return 0 ;
      if ( current1 >= string1 ) {
         c1 = (unsigned char) *current1 ;
         if ( ismbstrail ( string1, current1 ) ) c1 += 0x100 ;
      }
      else {
         c1 = 0 ;
      }
      if ( current2 >= string2 ) {
         c2 = (unsigned char) *current2 ;
         if ( ismbstrail ( string2, current2 ) ) c2 += 0x100 ;
      }
      else {
         c2 = 0 ;
      }
      if ( ! c1 || c1 != c2 ) break ;
      current1 -- ;
      current2 -- ;
      count -- ;
   }

   return c1 - c2 ;
}



////////////////////////////////////////////
//               strrnicmp ()             //
////////////////////////////////////////////



// 暥帤楍傪枛旜偐傜 ignore case 偱斾妑乮ANSI斉乯
int strrnicmp ( const char *string1, const char *string2, size_t count ) {

   int c1, c2 ;

   const char *current1 = strend ( string1 ) - 1 ;
   const char *current2 = strend ( string2 ) - 1 ;

   while ( 1 ) {
      if ( ! count ) return 0 ;
      if ( current1 >= string1 ) c1 = tolower ( (unsigned char) *current1 ) ;
      else                       c1 = 0 ;
      if ( current2 >= string2 ) c2 = tolower ( (unsigned char) *current2 ) ;
      else                       c2 = 0 ;
      if ( ! c1 || c1 != c2 ) break ;
      current1 -- ;
      current2 -- ;
      count -- ;
   }

   return c1 - c2 ;
}



// 暥帤楍傪枛旜偐傜 ignore case 偱斾妑乮UNICODE斉乯
int wcsrnicmp ( const wchar_t *string1, const wchar_t *string2, size_t count ) {

   int c1, c2 ;

   const wchar_t *current1 = wcsend ( string1 ) - 1 ;
   const wchar_t *current2 = wcsend ( string2 ) - 1 ;

   while ( 1 ) {
      if ( ! count ) return 0 ;
      if ( current1 >= string1 ) c1 = tolower ( *current1 ) ;
      else                       c1 = 0 ;
      if ( current2 >= string2 ) c2 = tolower ( *current2 ) ;
      else                       c2 = 0 ;
      if ( ! c1 || c1 != c2 ) break ;
      current1 -- ;
      current2 -- ;
      count -- ;
   }

   return c1 - c2 ;
}



// 暥帤楍傪枛旜偐傜 ignore case 偱斾妑乮UTF32斉乯
int wcsrnicmp32 ( const wchar32_t *string1, const wchar32_t *string2, size_t count ) {

   int c1, c2 ;

   const wchar32_t *current1 = wcsend32 ( string1 ) - 1 ;
   const wchar32_t *current2 = wcsend32 ( string2 ) - 1 ;

   while ( 1 ) {
      if ( ! count ) return 0 ;
      if ( current1 >= string1 ) c1 = tolower ( *current1 ) ;
      else                       c1 = 0 ;
      if ( current2 >= string2 ) c2 = tolower ( *current2 ) ;
      else                       c2 = 0 ;
      if ( ! c1 || c1 != c2 ) break ;
      current1 -- ;
      current2 -- ;
      count -- ;
   }

   return c1 - c2 ;
}



// 暥帤楍傪枛旜偐傜 ignore case 偱斾妑乮MULTIBYTE斉乯
int mbsrnicmp ( const char *string1, const char *string2, size_t count ) {

   int c1, c2 ;

   const char *current1 = strend ( string1 ) - 1 ;
   const char *current2 = strend ( string2 ) - 1 ;

   while ( 1 ) {
      if ( ! count ) return 0 ;
      if ( current1 >= string1 ) {
         c1 = (unsigned char) *current1 ;
         if ( ismbstrail ( string1, current1 ) ) c1 += 0x100 ;
         c1 = tolower ( c1 ) ;
      }
      else {
         c1 = 0 ;
      }
      if ( current2 >= string2 ) {
         c2 = (unsigned char) *current2 ;
         if ( ismbstrail ( string2, current2 ) ) c2 += 0x100 ;
         c2 = tolower ( c2 ) ;
      }
      else {
         c2 = 0 ;
      }
      if ( ! c1 || c1 != c2 ) break ;
      current1 -- ;
      current2 -- ;
      count -- ;
   }

   return c1 - c2 ;
}



////////////////////////////////////////////
//              strheadcmp ()             //
////////////////////////////////////////////



// 暥帤楍偺愭摢傪斾妑乮ANSI斉乯
int strheadcmp ( const char *string, const char *head ) {
   return strncmp ( string, head, strlen ( head ) ) ;
}



// 暥帤楍偺愭摢傪斾妑乮UNICODE斉乯
int wcsheadcmp ( const wchar_t *string, const wchar_t *head ) {
   return wcsncmp ( string, head, wcslen ( head ) ) ;
}



// 暥帤楍偺愭摢傪斾妑乮UTF32斉乯
int wcsheadcmp32 ( const wchar32_t *string, const wchar32_t *head ) {
   return wcsncmp32 ( string, head, wcslen32 ( head ) ) ;
}



////////////////////////////////////////////
//              strheadicmp ()            //
////////////////////////////////////////////



// 暥帤楍偺愭摢傪 ignore case 偱斾妑乮ANSI斉乯
int strheadicmp ( const char *string, const char *head ) {
   return strnicmp ( string, head, strlen ( head ) ) ;
}



// 暥帤楍偺愭摢傪 ignore case 偱斾妑乮UNICODE斉乯
int wcsheadicmp ( const wchar_t *string, const wchar_t *head ) {
   return wcsnicmp ( string, head, wcslen ( head ) ) ;
}



// 暥帤楍偺愭摢傪 ignore case 偱斾妑乮UTF32斉乯
int wcsheadicmp32 ( const wchar32_t *string, const wchar32_t *head ) {
   return wcsnicmp32 ( string, head, wcslen32 ( head ) ) ;
}



// 暥帤楍偺愭摢傪 ignore case 偱斾妑乮MULTIBYTE斉乯
int mbsheadicmp ( const char *string, const char *head ) {
   return mbsnicmp ( string, head, strlen ( head ) ) ;
}



////////////////////////////////////////////
//              strtailcmp ()             //
////////////////////////////////////////////



// 暥帤楍偺枛旜傪斾妑乮ANSI斉乯
int strtailcmp ( const char *string, const char *tail ) {
   return strrncmp ( string, tail, strlen ( tail ) ) ;
}



// 暥帤楍偺枛旜傪斾妑乮UNICODE斉乯
int wcstailcmp ( const wchar_t *string, const wchar_t *tail ) {
   return wcsrncmp ( string, tail, wcslen ( tail ) ) ;
}



// 暥帤楍偺枛旜傪斾妑乮UTF32斉乯
int wcstailcmp32 ( const wchar32_t *string, const wchar32_t *tail ) {
   return wcsrncmp32 ( string, tail, wcslen32 ( tail ) ) ;
}



// 暥帤楍偺枛旜傪斾妑乮MULTIBYTE斉乯
int mbstailcmp ( const char *string, const char *tail ) {
   return mbsrncmp ( string, tail, strlen ( tail ) ) ;
}



////////////////////////////////////////////
//              strtailicmp ()            //
////////////////////////////////////////////



// 暥帤楍偺枛旜傪 ignore case 偱斾妑乮ANSI斉乯

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -