📄 pgpunicode.h
字号:
/*____________________________________________________________________________
Copyright (C) 2002 Networks Associates Technology, Inc.
All rights reserved.
pgpUnicode.h - cross-platform Unicode conversion calls
$Id: pgpUnicode.h,v 1.3 2002/11/12 03:57:42 ajivsov Exp $
____________________________________________________________________________*/
#ifndef Included_pgpUnicode_h /* [ */
#define Included_pgpUnicode_h
#include "pgpTypes.h"
#include "pgpPFLErrors.h"
/*____________________________________________________________________________
* For functions that accept a 'Flags' value, passing kPGPUnicodeFlag_Secure
* will cause the function to break up strings into individual characters
* when passing info to OS-supplied conversion functions. This prevents
* buffers of sensitive information being leaked by the OS routines.
*/
#define kPGPUnicodeNullTerminated 0xFFFFFFFF
PGP_BEGIN_C_DECLARATIONS
/*____________________________________________________________________________
* Convert a string from Unicode UTF-8 to UCS-2. This doesn't call
* into any system functions and thus is secure.
*
* The output will be Null-terminated, if there is room in the output
* buffer. The output length does not include the terminating Null.
* If the input string is not a valid UTF-8 string, the output length
* will be returned as zero and the return value will indicate the
* position of the invalid character in the input string.
*
* If the input string is Null-terminated, you can avoid calculating
* the length and just pass in kPGPUnicodeNullTerminated for uLenUTF8.
*
* You can pass in NULL for wszWide if you don't want the output, but
* just want to get the output length (for allocating buffers, etc.).
*
* You can pass in NULL for puLenOut if you don't care about the output
* length.
*
* The return value is the number of bytes used from the input string.
* If there is an error in the conversion, the return value is the
* byte offset of the first offending character in the input string.
*/
PGPUInt32
pgpUTF8StringToUCS2 (
const char* pszUTF8,
PGPUInt32 uLenUTF8,
PGPUInt16* wszWide,
PGPUInt32 uMaxLenWide,
PGPUInt32* puLenOut);
/*____________________________________________________________________________
* Convert a string from Unicode UCS-2 to UTF-8. This doesn't call
* into any system functions and thus is secure.
*
* The output will be Null-terminated, if there is room in the outpub
* buffer. The output length does not include the terminating Null.
*
* If the input string is Null-terminated, you can avoid calculating
* the length and just pass in kPGPUnicodeNullTerminated for uLenWide.
*
* You can pass in Null for pszUTF8 if you don't want the output, but
* just want to get the output length (for allocating buffers, etc.).
*
* You can pass in Null for puLenOut if you don't care about the output
* length.
*
* The return value is the number of wide chars used from the input string.
*/
PGPUInt32
pgpUCS2StringToUTF8 (
PGPUInt16* wszWide,
PGPUInt32 uLenWide,
char* pszUTF8,
PGPUInt32 uMaxLenUTF8,
PGPUInt32* puLenOut);
/*____________________________________________________________________________
* Determine if the input string is not a 7-bit ASCII string (i.e. test
* if any of the bytes have bit-8 set). It's easier to test if a string is
* *not* ASCII than to prove that it is!
*
* If the input string is Null-terminated, you can avoid calculating
* the length and just pass in kPGPUnicodeNullTerminated for uLength.
*/
PGPBoolean
pgpIsntASCIIString (
char* pszString,
PGPUInt32 uLength);
/*____________________________________________________________________________
* Determine if the input string is a valid UTF-8 encoded string. It's
* easier to test if a string is *not* UTF-8 than to prove that it is!
*
* If the input string is Null-terminated, you can avoid calculating
* the length and just pass in kPGPUnicodeNullTerminated for uLength.
*/
PGPBoolean
pgpIsntUTF8String (
char* pszString,
PGPUInt32 uLength);
/*____________________________________________________________________________
* Convert UCS2 string to uppercase
*/
void
pgpUCS2StringToUpper( PGPUInt16 *in, PGPSize outSize );
/* ____________________________________________________________________________
* Return TRUE for Unicode whitespace character
*/
PGPBoolean
pgpUnicodeCharIsWhitespace( PGPUInt32 c );
/* ____________________________________________________________________________
* Return TRUE for Unicode punctuation character
*/
PGPBoolean
pgpUnicodeCharIsPunctuation( PGPUInt32 c );
PGP_END_C_DECLARATIONS
#endif /* ] */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -