michael@0: /* michael@0: ******************************************************************************* michael@0: * michael@0: * Copyright (C) 1999-2010, International Business Machines michael@0: * Corporation and others. All Rights Reserved. michael@0: * michael@0: ******************************************************************************* michael@0: * file name: uinvchar.h michael@0: * encoding: US-ASCII michael@0: * tab size: 8 (not used) michael@0: * indentation:2 michael@0: * michael@0: * created on: 2004sep14 michael@0: * created by: Markus W. Scherer michael@0: * michael@0: * Definitions for handling invariant characters, moved here from putil.c michael@0: * for better modularization. michael@0: */ michael@0: michael@0: #ifndef __UINVCHAR_H__ michael@0: #define __UINVCHAR_H__ michael@0: michael@0: #include "unicode/utypes.h" michael@0: michael@0: /** michael@0: * Check if a char string only contains invariant characters. michael@0: * See utypes.h for details. michael@0: * michael@0: * @param s Input string pointer. michael@0: * @param length Length of the string, can be -1 if NUL-terminated. michael@0: * @return TRUE if s contains only invariant characters. michael@0: * michael@0: * @internal (ICU 2.8) michael@0: */ michael@0: U_INTERNAL UBool U_EXPORT2 michael@0: uprv_isInvariantString(const char *s, int32_t length); michael@0: michael@0: /** michael@0: * Check if a Unicode string only contains invariant characters. michael@0: * See utypes.h for details. michael@0: * michael@0: * @param s Input string pointer. michael@0: * @param length Length of the string, can be -1 if NUL-terminated. michael@0: * @return TRUE if s contains only invariant characters. michael@0: * michael@0: * @internal (ICU 2.8) michael@0: */ michael@0: U_INTERNAL UBool U_EXPORT2 michael@0: uprv_isInvariantUString(const UChar *s, int32_t length); michael@0: michael@0: /** michael@0: * \def U_UPPER_ORDINAL michael@0: * Get the ordinal number of an uppercase invariant character michael@0: * @internal michael@0: */ michael@0: #if U_CHARSET_FAMILY==U_ASCII_FAMILY michael@0: # define U_UPPER_ORDINAL(x) ((x)-'A') michael@0: #elif U_CHARSET_FAMILY==U_EBCDIC_FAMILY michael@0: # define U_UPPER_ORDINAL(x) (((x) < 'J') ? ((x)-'A') : \ michael@0: (((x) < 'S') ? ((x)-'J'+9) : \ michael@0: ((x)-'S'+18))) michael@0: #else michael@0: # error Unknown charset family! michael@0: #endif michael@0: michael@0: /** michael@0: * Compare two EBCDIC invariant-character strings in ASCII order. michael@0: * @internal michael@0: */ michael@0: U_INTERNAL int32_t U_EXPORT2 michael@0: uprv_compareInvEbcdicAsAscii(const char *s1, const char *s2); michael@0: michael@0: /** michael@0: * \def uprv_compareInvCharsAsAscii michael@0: * Compare two invariant-character strings in ASCII order. michael@0: * @internal michael@0: */ michael@0: #if U_CHARSET_FAMILY==U_ASCII_FAMILY michael@0: # define uprv_compareInvCharsAsAscii(s1, s2) uprv_strcmp(s1, s2) michael@0: #elif U_CHARSET_FAMILY==U_EBCDIC_FAMILY michael@0: # define uprv_compareInvCharsAsAscii(s1, s2) uprv_compareInvEbcdicAsAscii(s1, s2) michael@0: #else michael@0: # error Unknown charset family! michael@0: #endif michael@0: michael@0: /** michael@0: * Converts an EBCDIC invariant character to lowercase ASCII. michael@0: * @internal michael@0: */ michael@0: U_INTERNAL char U_EXPORT2 michael@0: uprv_ebcdicToLowercaseAscii(char c); michael@0: michael@0: /** michael@0: * \def uprv_invCharToLowercaseAscii michael@0: * Converts an invariant character to lowercase ASCII. michael@0: * @internal michael@0: */ michael@0: #if U_CHARSET_FAMILY==U_ASCII_FAMILY michael@0: # define uprv_invCharToLowercaseAscii uprv_asciitolower michael@0: #elif U_CHARSET_FAMILY==U_EBCDIC_FAMILY michael@0: # define uprv_invCharToLowercaseAscii uprv_ebcdicToLowercaseAscii michael@0: #else michael@0: # error Unknown charset family! michael@0: #endif michael@0: michael@0: /** michael@0: * Copy EBCDIC to ASCII michael@0: * @internal michael@0: * @see uprv_strncpy michael@0: */ michael@0: U_INTERNAL uint8_t* U_EXPORT2 michael@0: uprv_aestrncpy(uint8_t *dst, const uint8_t *src, int32_t n); michael@0: michael@0: michael@0: /** michael@0: * Copy ASCII to EBCDIC michael@0: * @internal michael@0: * @see uprv_strncpy michael@0: */ michael@0: U_INTERNAL uint8_t* U_EXPORT2 michael@0: uprv_eastrncpy(uint8_t *dst, const uint8_t *src, int32_t n); michael@0: michael@0: michael@0: michael@0: #endif