Share via


_strdec, _wcsdec, _mbsdec, _mbsdec_l

將字串指標後移一個字元。

重要

在 Windows 執行階段中執行的應用程式中無法使用 _mbsdec_mbsdec_l。 如需詳細資訊,請參閱 CRT functions not supported in Universal Windows Platform apps (通用 Windows 平台應用程式中不支援的 CRT 函式)。

語法

unsigned char *_strdec(
   const unsigned char *start,
   const unsigned char *current
);
unsigned wchar_t *_wcsdec(
   const unsigned wchar_t *start,
   const unsigned wchar_t *current
);
unsigned char *_mbsdec(
   const unsigned char *start,
   const unsigned char *current
);
unsigned char *_mbsdec_l(
   const unsigned char *start,
   const unsigned char *current,
   _locale_t locale
);

參數

start
來源字串中任何字元的指標(或 為 _mbsdec_mbsdec_l ,任何多位元組字元的第一個位元組); start 必須在來源字串前面 current

current
來源字串 current 中任何字元的指標(或 為 _mbsdec_mbsdec_l ,任何多位元組字元的第一個位元組;必須在來源字串中追蹤 start

locale
要使用的地區設定。

傳回值

_mbsdec、 、 和 每個 都會傳回緊接在 前面的 current 字元指標; _mbsdec 如果 的值 start 大於或等於 的 current ,則傳回 NULL_wcsdec_strdec_mbsdec_l _tcsdec 會對應至其中一個函式,而其傳回值則取決於此對應。

備註

_mbsdec_mbsdec_l 函式會傳回緊接在包含 start 的字串中 current 之前的多位元組字元的第一個位元組指標。

輸出值會受到 LC_CTYPE 地區設定之類別設定的影響。 如需詳細資訊,請參閱 setlocale_wsetlocale_mbsdec 會根據目前使用的地區設定來辨識多位元組字元序列,而 _mbsdec_l 與其相同,只不過它會改用傳入的地區設定參數。 如需詳細資訊,請參閱 Locale

如果 startcurrentNULL ,則會叫用不正確參數處理常式,如參數驗證 中所述 。 若允許繼續執行,此函式會傳回 EINVAL,並將 errno 設為 EINVAL

重要

這些函式可能容易受到緩衝區滿溢的威脅。 緩衝區滿溢可能被當成系統攻擊方式,因為它們可能導致非預期的提高權限。 如需詳細資訊,請參閱 避免緩衝區滿溢

根據預設,此函式的全域狀態會限定于應用程式。 若要變更此行為,請參閱 CRT 中的全域狀態。

泛型文字常式對應

Tchar.h 常式 _UNICODE_MBCS 未定義 _MBCS 定義 _UNICODE 定義
_tcsdec _strdec _mbsdec _wcsdec

_strdec_wcsdec_mbsdec_mbsdec_l 的單一位元組字元版本和寬字元版本。 _strdec_wcsdec 僅針對此對應提供,否則不應使用。

如需詳細資訊,請參閱 使用泛型文字對應 泛型文字對應

需求

常式 必要的標頭 選擇性標頭
_mbsdec <mbstring.h> <mbctype.h>
_mbsdec_l <mbstring.h> <mbctype.h>
_strdec <tchar.h>
_wcsdec <tchar.h>

如需相容性詳細資訊,請參閱相容性

範例

下列範例示範 _tcsdec 的用法。

// crt_tcsdec.cpp
// Compile by using: cl /EHsc crt_tcsdec.cpp
#include <iostream>
#include <tchar.h>
using namespace std;

int main()
{
   const TCHAR *str = _T("12345");
   cout << "str: " << str << endl;

   const TCHAR *str2;
   str2 = str + 2;
   cout << "str2: " << str2 << endl;

   TCHAR *answer;
   answer = _tcsdec( str, str2 );
   cout << "answer: " << answer << endl;

   return (0);
}

下列範例示範 _mbsdec 的用法。

// crt_mbsdec.cpp
// Compile by using: cl /EHsc crt_mbsdec.c
#include <iostream>
#include <mbstring.h>
using namespace std;

int main()
{
   char *str = "12345";
   cout << "str: " << str << endl;

   char *str2;
   str2 = str + 2;
   cout << "str2: " << str2 << endl;

   unsigned char *answer;
   answer = _mbsdec( reinterpret_cast<unsigned char *>( str ), reinterpret_cast<unsigned char *>( str2 ));

   cout << "answer: " << answer << endl;

   return (0);
}

另請參閱

字串操作
_strinc, _wcsinc, _mbsinc, _mbsinc_l
_strnextc, _wcsnextc, _mbsnextc, _mbsnextc_l
_strninc, _wcsninc, _mbsninc, _mbsninc_l