Back to index

lightning-sunbird  0.9+nobinonly
Defines | Typedefs | Functions
unistring.h File Reference
#include <stdio.h>
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define U_NUL   0x00U
#define U_CTL_A   0x01U
#define U_CTL_B   0x02U
#define U_CTL_C   0x03U
#define U_CTL_D   0x04U
#define U_CTL_E   0x05U
#define U_CTL_F   0x06U
#define U_BEL   0x07U /* ^G */
#define U_BACKSPACE   0x08U /* ^H */
#define U_TAB   0x09U /* ^I */
#define U_LINEFEED   0x0AU /* ^J */
#define U_CTL_K   0x0BU
#define U_CTL_L   0x0CU
#define U_CRETURN   0x0DU /* ^M */
#define U_CTL_N   0x0EU
#define U_CTL_O   0x0FU
#define U_CTL_P   0x10U
#define U_CTL_Q   0x11U
#define U_CTL_R   0x12U
#define U_CTL_S   0x13U
#define U_CTL_T   0x14U
#define U_CTL_U   0x15U
#define U_CTL_V   0x16U
#define U_CTL_W   0x17U
#define U_CTL_X   0x18U
#define U_CTL_Y   0x19U
#define U_CTL_Z   0x1AU
#define U_ESCAPE   0x1BU /* escape */
#define U_SPACE   0x20U /* space */
#define U_EXCLAMATION   0x21U /* ! */
#define U_DBLQUOTE   0x22U /* " */
#define U_NUMBER   0x23U /* # */
#define U_DOLLAR   0x24U /* $ */
#define U_PERCENT   0x25U /* % */
#define U_AMPERSAND   0x26U /* & */
#define U_SNGLQUOTE   0x27U /* ' */
#define U_LPAREN   0x28U /* ( */
#define U_RPAREN   0x29U /* ) */
#define U_STAR   0x2AU /* * */
#define U_PLUS   0x2BU /* + */
#define U_COMMA   0x2CU /* , */
#define U_DASH   0x2DU /* - */
#define U_PERIOD   0x2EU /* . */
#define U_SLASH   0x2FU /* / */
#define U_ZERO   0x30U /* 0 */
#define U_ONE   0x31U /* 1 */
#define U_TWO   0x32U /* 2 */
#define U_THREE   0x33U /* 3 */
#define U_FOUR   0x34U /* 4 */
#define U_FIVE   0x35U /* 5 */
#define U_SIX   0x36U /* 6 */
#define U_SEVEN   0x37U /* 7 */
#define U_EIGHT   0x38U /* 8 */
#define U_NINE   0x39U /* 9 */
#define U_COLON   0x3AU /* : */
#define U_SEMICOLON   0x3BU /* ; */
#define U_LESSTHAN   0x3CU /* < */
#define U_EQUALS   0x3DU /* = */
#define U_GREATERTHAN   0x3EU /* > */
#define U_QUERYMARK   0x3FU /* ? */
#define U_ATSIGN   0x40U /* @ */
#define U_A_CHAR   0x41U /* A */
#define U_B_CHAR   0x42U /* B */
#define U_C_CHAR   0x43U /* C */
#define U_D_CHAR   0x44U /* D */
#define U_E_CHAR   0x45U /* E */
#define U_F_CHAR   0x46U /* F */
#define U_G_CHAR   0x47U /* G */
#define U_H_CHAR   0x48U /* H */
#define U_I_CHAR   0x49U /* I */
#define U_J_CHAR   0x4AU /* J */
#define U_K_CHAR   0x4BU /* K */
#define U_L_CHAR   0x4CU /* L */
#define U_M_CHAR   0x4DU /* M */
#define U_N_CHAR   0x4EU /* N */
#define U_O_CHAR   0x4FU /* O */
#define U_P_CHAR   0x50U /* P */
#define U_Q_CHAR   0x51U /* Q */
#define U_R_CHAR   0x52U /* R */
#define U_S_CHAR   0x53U /* S */
#define U_T_CHAR   0x54U /* T */
#define U_U_CHAR   0x55U /* U */
#define U_V_CHAR   0x56U /* V */
#define U_W_CHAR   0x57U /* W */
#define U_X_CHAR   0x58U /* X */
#define U_Y_CHAR   0x59U /* Y */
#define U_Z_CHAR   0x5AU /* Z */
#define U_LBRACKET   0x5BU /* [ */
#define U_BACKSLASH   0x5CU /* \ */
#define U_RBRACKET   0x5DU /* ] */
#define U_CARET   0x5EU /* ^ */
#define U_UNDERSCORE   0x5FU /* _ */
#define U_BACKQUOTE   0x60U /* ` */
#define U_a_CHAR   0x61U /* a */
#define U_b_CHAR   0x62U /* b */
#define U_c_CHAR   0x63U /* c */
#define U_d_CHAR   0x64U /* d */
#define U_e_CHAR   0x65U /* e */
#define U_f_CHAR   0x66U /* f */
#define U_g_CHAR   0x67U /* g */
#define U_h_CHAR   0x68U /* h */
#define U_i_CHAR   0x69U /* i */
#define U_j_CHAR   0x6AU /* j */
#define U_k_CHAR   0x6BU /* k */
#define U_l_CHAR   0x6CU /* l */
#define U_m_CHAR   0x6DU /* m */
#define U_n_CHAR   0x6EU /* n */
#define U_o_CHAR   0x6FU /* o */
#define U_p_CHAR   0x70U /* p */
#define U_q_CHAR   0x71U /* q */
#define U_r_CHAR   0x72U /* r */
#define U_s_CHAR   0x73U /* s */
#define U_t_CHAR   0x74U /* t */
#define U_u_CHAR   0x75U /* u */
#define U_v_CHAR   0x76U /* v */
#define U_w_CHAR   0x77U /* w */
#define U_x_CHAR   0x78U /* x */
#define U_y_CHAR   0x79U /* y */
#define U_z_CHAR   0x7AU /* z */
#define U_LCURLY   0x7BU /* { */
#define U_VERTBAR   0x7CU /* | */
#define U_RCURLY   0x7DU /* } */
#define U_TILDE   0x7EU /* ~ */
#define U_DEL   0x7FU /* delete */
#define U_LATIN1LO   0xA0U /* lowest Latin1 extension character */
#define U_NOBRKSPACE   0xA0U /* no-break space */
#define U_LATIN1HI   0xFFU /* highest Latin1 extension character */
#define U_PRIVATE0   0xE000U /* first private use Unicode character */
#define IS_ASCII_LETTER(x)
#define IS_ASCII_DIGIT(x)

Typedefs

typedef unsigned short UNICHAR

Functions

void ucstoutf8 (const UNICHAR *us, int nus, char *s, int ns, int *remaining, int *encoded)
 Encodes Unicode string US with NUS characters into UTF8 string S with upto NS characters, returning the number of REMAINING Unicode characters and the number of ENCODED Utf8 characters.
int utf8toucs (const char *s, int ns, UNICHAR *us, int nus, int skipNUL, int *remaining, int *decoded)
 Decodes UTF8 string S with NS characters to Unicode string US with upto NUS characters, returning the number of REMAINING Utf8 characters and the number of DECODED Unicode characters.
void ucsprint (FILE *stream, const UNICHAR *us, int nus)
 Prints Unicode string US with NUS characters to file stream STREAM, escaping non-printable ASCII characters and all non-ASCII characters.
UNICHARucscopy (UNICHAR *dest, const char *srcplain, size_t n)
 Copy exactly n characters from plain character source string to UNICHAR destination string, ignoring source characters past a null character and padding the destination with null characters if necessary.
UNICHARucschr (const UNICHAR *str, const UNICHAR chr)
 Locates first occurrence of character within string and returns pointer to it if found, else returning null pointer.
UNICHARucsrchr (const UNICHAR *str, const UNICHAR chr)
 Locates last occurrence of character within string and returns pointer to it if found, else returning null pointer.
int ucscmp (register const UNICHAR *str1, register const UNICHAR *str2)
 Compare all characters between string1 and string2, returning a zero value if all characters are equal, or returning character1 - character2 for the first character that is different between the two strings.
int ucsncmp (const UNICHAR *str1, const UNICHAR *str2, size_t n)
 Compare upto n characters between string1 and string2, returning a zero value if all compared characters are equal, or returning character1 - character2 for the first character that is different between the two strings.
UNICHARucsncpy (UNICHAR *dest, const UNICHAR *src, size_t n)
 Copy exactly n characters from source to destination, ignoring source characters past a null character and padding the destination with null characters if necessary.
size_t ucslen (const UNICHAR *str)
 Returns string length.
UNICHARucsstr (const UNICHAR *str, const UNICHAR *substr)
 Locates substring within string and returns pointer to it if found, else returning null pointer.
size_t ucsspn (const UNICHAR *str, const UNICHAR *chars)
 Returns length of longest initial segment of string that contains only the specified characters.
size_t ucscspn (const UNICHAR *str, const UNICHAR *chars)
 Returns length of longest initial segment of string that does not contain any of the specified characters.

Define Documentation

Value:
( ((x) >= (UNICHAR)U_ZERO) && \
                             ((x) <= (UNICHAR)U_NINE) )

Definition at line 338 of file unistring.h.

Value:
( (((x) >= (UNICHAR)U_A_CHAR) &&  \
                              ((x) <= (UNICHAR)U_Z_CHAR)) || \
                             (((x) >= (UNICHAR)U_a_CHAR) &&  \
                              ((x) <= (UNICHAR)U_z_CHAR)) )

Definition at line 333 of file unistring.h.

#define U_A_CHAR   0x41U /* A */

Definition at line 258 of file unistring.h.

#define U_a_CHAR   0x61U /* a */

Definition at line 293 of file unistring.h.

#define U_AMPERSAND   0x26U /* & */

Definition at line 226 of file unistring.h.

#define U_ATSIGN   0x40U /* @ */

Definition at line 256 of file unistring.h.

#define U_B_CHAR   0x42U /* B */

Definition at line 259 of file unistring.h.

#define U_b_CHAR   0x62U /* b */

Definition at line 294 of file unistring.h.

#define U_BACKQUOTE   0x60U /* ` */

Definition at line 291 of file unistring.h.

#define U_BACKSLASH   0x5CU /* \ */

Definition at line 286 of file unistring.h.

#define U_BACKSPACE   0x08U /* ^H */

Definition at line 195 of file unistring.h.

#define U_BEL   0x07U /* ^G */

Definition at line 194 of file unistring.h.

#define U_C_CHAR   0x43U /* C */

Definition at line 260 of file unistring.h.

#define U_c_CHAR   0x63U /* c */

Definition at line 295 of file unistring.h.

#define U_CARET   0x5EU /* ^ */

Definition at line 289 of file unistring.h.

#define U_COLON   0x3AU /* : */

Definition at line 249 of file unistring.h.

#define U_COMMA   0x2CU /* , */

Definition at line 233 of file unistring.h.

#define U_CRETURN   0x0DU /* ^M */

Definition at line 202 of file unistring.h.

#define U_CTL_A   0x01U

Definition at line 187 of file unistring.h.

#define U_CTL_B   0x02U

Definition at line 188 of file unistring.h.

#define U_CTL_C   0x03U

Definition at line 189 of file unistring.h.

#define U_CTL_D   0x04U

Definition at line 190 of file unistring.h.

#define U_CTL_E   0x05U

Definition at line 191 of file unistring.h.

#define U_CTL_F   0x06U

Definition at line 192 of file unistring.h.

#define U_CTL_K   0x0BU

Definition at line 199 of file unistring.h.

#define U_CTL_L   0x0CU

Definition at line 200 of file unistring.h.

#define U_CTL_N   0x0EU

Definition at line 204 of file unistring.h.

#define U_CTL_O   0x0FU

Definition at line 205 of file unistring.h.

#define U_CTL_P   0x10U

Definition at line 206 of file unistring.h.

#define U_CTL_Q   0x11U

Definition at line 207 of file unistring.h.

#define U_CTL_R   0x12U

Definition at line 208 of file unistring.h.

#define U_CTL_S   0x13U

Definition at line 209 of file unistring.h.

#define U_CTL_T   0x14U

Definition at line 210 of file unistring.h.

#define U_CTL_U   0x15U

Definition at line 211 of file unistring.h.

#define U_CTL_V   0x16U

Definition at line 212 of file unistring.h.

#define U_CTL_W   0x17U

Definition at line 213 of file unistring.h.

#define U_CTL_X   0x18U

Definition at line 214 of file unistring.h.

#define U_CTL_Y   0x19U

Definition at line 215 of file unistring.h.

#define U_CTL_Z   0x1AU

Definition at line 216 of file unistring.h.

#define U_D_CHAR   0x44U /* D */

Definition at line 261 of file unistring.h.

#define U_d_CHAR   0x64U /* d */

Definition at line 296 of file unistring.h.

#define U_DASH   0x2DU /* - */

Definition at line 234 of file unistring.h.

#define U_DBLQUOTE   0x22U /* " */

Definition at line 222 of file unistring.h.

#define U_DEL   0x7FU /* delete */

Definition at line 325 of file unistring.h.

#define U_DOLLAR   0x24U /* $ */

Definition at line 224 of file unistring.h.

#define U_E_CHAR   0x45U /* E */

Definition at line 262 of file unistring.h.

#define U_e_CHAR   0x65U /* e */

Definition at line 297 of file unistring.h.

#define U_EIGHT   0x38U /* 8 */

Definition at line 246 of file unistring.h.

#define U_EQUALS   0x3DU /* = */

Definition at line 252 of file unistring.h.

#define U_ESCAPE   0x1BU /* escape */

Definition at line 218 of file unistring.h.

#define U_EXCLAMATION   0x21U /* ! */

Definition at line 221 of file unistring.h.

#define U_F_CHAR   0x46U /* F */

Definition at line 263 of file unistring.h.

#define U_f_CHAR   0x66U /* f */

Definition at line 298 of file unistring.h.

#define U_FIVE   0x35U /* 5 */

Definition at line 243 of file unistring.h.

#define U_FOUR   0x34U /* 4 */

Definition at line 242 of file unistring.h.

#define U_G_CHAR   0x47U /* G */

Definition at line 264 of file unistring.h.

#define U_g_CHAR   0x67U /* g */

Definition at line 299 of file unistring.h.

#define U_GREATERTHAN   0x3EU /* > */

Definition at line 253 of file unistring.h.

#define U_H_CHAR   0x48U /* H */

Definition at line 265 of file unistring.h.

#define U_h_CHAR   0x68U /* h */

Definition at line 300 of file unistring.h.

#define U_I_CHAR   0x49U /* I */

Definition at line 266 of file unistring.h.

#define U_i_CHAR   0x69U /* i */

Definition at line 301 of file unistring.h.

#define U_J_CHAR   0x4AU /* J */

Definition at line 267 of file unistring.h.

#define U_j_CHAR   0x6AU /* j */

Definition at line 302 of file unistring.h.

#define U_K_CHAR   0x4BU /* K */

Definition at line 268 of file unistring.h.

#define U_k_CHAR   0x6BU /* k */

Definition at line 303 of file unistring.h.

#define U_L_CHAR   0x4CU /* L */

Definition at line 269 of file unistring.h.

#define U_l_CHAR   0x6CU /* l */

Definition at line 304 of file unistring.h.

#define U_LATIN1HI   0xFFU /* highest Latin1 extension character */

Definition at line 329 of file unistring.h.

#define U_LATIN1LO   0xA0U /* lowest Latin1 extension character */

Definition at line 327 of file unistring.h.

#define U_LBRACKET   0x5BU /* [ */

Definition at line 285 of file unistring.h.

#define U_LCURLY   0x7BU /* { */

Definition at line 320 of file unistring.h.

#define U_LESSTHAN   0x3CU /* < */

Definition at line 251 of file unistring.h.

#define U_LINEFEED   0x0AU /* ^J */

Definition at line 197 of file unistring.h.

#define U_LPAREN   0x28U /* ( */

Definition at line 228 of file unistring.h.

#define U_M_CHAR   0x4DU /* M */

Definition at line 270 of file unistring.h.

#define U_m_CHAR   0x6DU /* m */

Definition at line 305 of file unistring.h.

#define U_N_CHAR   0x4EU /* N */

Definition at line 271 of file unistring.h.

#define U_n_CHAR   0x6EU /* n */

Definition at line 306 of file unistring.h.

#define U_NINE   0x39U /* 9 */

Definition at line 247 of file unistring.h.

#define U_NOBRKSPACE   0xA0U /* no-break space */

Definition at line 328 of file unistring.h.

#define U_NUL   0x00U

Definition at line 185 of file unistring.h.

#define U_NUMBER   0x23U /* # */

Definition at line 223 of file unistring.h.

#define U_O_CHAR   0x4FU /* O */

Definition at line 272 of file unistring.h.

#define U_o_CHAR   0x6FU /* o */

Definition at line 307 of file unistring.h.

#define U_ONE   0x31U /* 1 */

Definition at line 239 of file unistring.h.

#define U_P_CHAR   0x50U /* P */

Definition at line 273 of file unistring.h.

#define U_p_CHAR   0x70U /* p */

Definition at line 308 of file unistring.h.

#define U_PERCENT   0x25U /* % */

Definition at line 225 of file unistring.h.

#define U_PERIOD   0x2EU /* . */

Definition at line 235 of file unistring.h.

#define U_PLUS   0x2BU /* + */

Definition at line 232 of file unistring.h.

#define U_PRIVATE0   0xE000U /* first private use Unicode character */

Definition at line 331 of file unistring.h.

#define U_Q_CHAR   0x51U /* Q */

Definition at line 274 of file unistring.h.

#define U_q_CHAR   0x71U /* q */

Definition at line 309 of file unistring.h.

#define U_QUERYMARK   0x3FU /* ? */

Definition at line 254 of file unistring.h.

#define U_R_CHAR   0x52U /* R */

Definition at line 275 of file unistring.h.

#define U_r_CHAR   0x72U /* r */

Definition at line 310 of file unistring.h.

#define U_RBRACKET   0x5DU /* ] */

Definition at line 287 of file unistring.h.

#define U_RCURLY   0x7DU /* } */

Definition at line 322 of file unistring.h.

#define U_RPAREN   0x29U /* ) */

Definition at line 229 of file unistring.h.

#define U_S_CHAR   0x53U /* S */

Definition at line 276 of file unistring.h.

#define U_s_CHAR   0x73U /* s */

Definition at line 311 of file unistring.h.

#define U_SEMICOLON   0x3BU /* ; */

Definition at line 250 of file unistring.h.

#define U_SEVEN   0x37U /* 7 */

Definition at line 245 of file unistring.h.

#define U_SIX   0x36U /* 6 */

Definition at line 244 of file unistring.h.

#define U_SLASH   0x2FU /* / */

Definition at line 236 of file unistring.h.

#define U_SNGLQUOTE   0x27U /* ' */

Definition at line 227 of file unistring.h.

#define U_SPACE   0x20U /* space */

Definition at line 220 of file unistring.h.

#define U_STAR   0x2AU /* * */

Definition at line 231 of file unistring.h.

#define U_T_CHAR   0x54U /* T */

Definition at line 277 of file unistring.h.

#define U_t_CHAR   0x74U /* t */

Definition at line 312 of file unistring.h.

#define U_TAB   0x09U /* ^I */

Definition at line 196 of file unistring.h.

#define U_THREE   0x33U /* 3 */

Definition at line 241 of file unistring.h.

#define U_TILDE   0x7EU /* ~ */

Definition at line 324 of file unistring.h.

#define U_TWO   0x32U /* 2 */

Definition at line 240 of file unistring.h.

#define U_U_CHAR   0x55U /* U */

Definition at line 278 of file unistring.h.

#define U_u_CHAR   0x75U /* u */

Definition at line 313 of file unistring.h.

#define U_UNDERSCORE   0x5FU /* _ */

Definition at line 290 of file unistring.h.

#define U_V_CHAR   0x56U /* V */

Definition at line 279 of file unistring.h.

#define U_v_CHAR   0x76U /* v */

Definition at line 314 of file unistring.h.

#define U_VERTBAR   0x7CU /* | */

Definition at line 321 of file unistring.h.

#define U_W_CHAR   0x57U /* W */

Definition at line 280 of file unistring.h.

#define U_w_CHAR   0x77U /* w */

Definition at line 315 of file unistring.h.

#define U_X_CHAR   0x58U /* X */

Definition at line 281 of file unistring.h.

#define U_x_CHAR   0x78U /* x */

Definition at line 316 of file unistring.h.

#define U_Y_CHAR   0x59U /* Y */

Definition at line 282 of file unistring.h.

#define U_y_CHAR   0x79U /* y */

Definition at line 317 of file unistring.h.

#define U_Z_CHAR   0x5AU /* Z */

Definition at line 283 of file unistring.h.

#define U_z_CHAR   0x7AU /* z */

Definition at line 318 of file unistring.h.

#define U_ZERO   0x30U /* 0 */

Definition at line 238 of file unistring.h.


Typedef Documentation

typedef unsigned short UNICHAR

Definition at line 63 of file unistring.h.


Function Documentation

UNICHAR* ucschr ( const UNICHAR str,
const UNICHAR  chr 
)

Locates first occurrence of character within string and returns pointer to it if found, else returning null pointer.

(character may be NUL)

int ucscmp ( register const UNICHAR str1,
register const UNICHAR str2 
)

Compare all characters between string1 and string2, returning a zero value if all characters are equal, or returning character1 - character2 for the first character that is different between the two strings.

(Characters following a null character are not compared.)

Definition at line 254 of file unistring.c.

{
  register UNICHAR ch1, ch2;

  do {
    if ((ch1 = *str1++) != (ch2 = *str2++))
      return ch1 - ch2;

  } while (ch1 != U_NUL);

  return 0;
}

Here is the caller graph for this function:

UNICHAR* ucscopy ( UNICHAR dest,
const char *  srcplain,
size_t  n 
)

Copy exactly n characters from plain character source string to UNICHAR destination string, ignoring source characters past a null character and padding the destination with null characters if necessary.

size_t ucscspn ( const UNICHAR str,
const UNICHAR chars 
)

Returns length of longest initial segment of string that does not contain any of the specified characters.

Definition at line 395 of file unistring.c.

{
  register UNICHAR strch, ch;
  register const UNICHAR* charscp;
  register const UNICHAR* strcp = str;

  while ((strch = *strcp++) != U_NUL) {
    charscp = chars;

    /* Check that it is not one of the specified characters */
    while ((ch = *charscp++) != U_NUL) {
      if (strch == ch)
        return (size_t) (strcp - str - 1);
    }
  }

  return (size_t) (strcp - str - 1);
}

Here is the caller graph for this function:

size_t ucslen ( const UNICHAR str)

Returns string length.

Definition at line 319 of file unistring.c.

{
  register const UNICHAR* strcp = str;

  while (*strcp++ != U_NUL);

  return strcp - str - 1;
}

Here is the caller graph for this function:

int ucsncmp ( const UNICHAR str1,
const UNICHAR str2,
size_t  n 
)

Compare upto n characters between string1 and string2, returning a zero value if all compared characters are equal, or returning character1 - character2 for the first character that is different between the two strings.

(Characters following a null character are not compared.)

UNICHAR* ucsncpy ( UNICHAR dest,
const UNICHAR src,
size_t  n 
)

Copy exactly n characters from source to destination, ignoring source characters past a null character and padding the destination with null characters if necessary.

void ucsprint ( FILE stream,
const UNICHAR us,
int  nus 
)

Prints Unicode string US with NUS characters to file stream STREAM, escaping non-printable ASCII characters and all non-ASCII characters.

Definition at line 158 of file unistring.c.

{
  static const char hexDigits[17] = "0123456789abcdef";
  UNICHAR uch;
  int k;

  for (k=0; k<nus; k++) {
    uch = us[k];

    if (uch < (UNICHAR)U_SPACE) {
      /* ASCII control character */
      fprintf(stream, "^%c", (char) uch+U_ATSIGN);

    } else if (uch == (UNICHAR)U_CARET) {
      /* Caret */
      fprintf(stream, "^^");

    } else if (uch < (UNICHAR)U_DEL) {
      /* Printable ASCII character */
      fprintf(stream, "%c", (char) uch);

    } else {
      /* DEL or non-ASCII character */
      char esc_str[8]="&#0000;";
      int j;
      for (j=5; j>1; j--) {
        esc_str[j] = hexDigits[uch%16];
        uch = uch / 16;
      }
      fprintf(stream, "%s", esc_str);
    }
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

UNICHAR* ucsrchr ( const UNICHAR str,
const UNICHAR  chr 
)

Locates last occurrence of character within string and returns pointer to it if found, else returning null pointer.

(character may be NUL)

size_t ucsspn ( const UNICHAR str,
const UNICHAR chars 
)

Returns length of longest initial segment of string that contains only the specified characters.

Definition at line 370 of file unistring.c.

{
  register UNICHAR strch, ch;
  register const UNICHAR* charscp;
  register const UNICHAR* strcp = str;

  while ((strch = *strcp++) != U_NUL) {
    charscp = chars;

    /* Check that it is one of the specified characters */
    while ((ch = *charscp++) != U_NUL) {
      if (strch == ch)
        break;
    }
    if (ch == U_NUL)
      return (size_t) (strcp - str - 1);
  }

  return (size_t) (strcp - str - 1);
}

Here is the caller graph for this function:

UNICHAR* ucsstr ( const UNICHAR str,
const UNICHAR substr 
)

Locates substring within string and returns pointer to it if found, else returning null pointer.

If substring has zero length, then full string is returned.

void ucstoutf8 ( const UNICHAR us,
int  nus,
char *  s,
int  ns,
int remaining,
int encoded 
)

Encodes Unicode string US with NUS characters into UTF8 string S with upto NS characters, returning the number of REMAINING Unicode characters and the number of ENCODED Utf8 characters.

Definition at line 48 of file unistring.c.

{
  int j, k;

  j = 0;
  k = 0;
  while ((j < ns) && (k < nus)) {
    UNICHAR uch = us[k++];

    if (uch < 0x0080) {
      s[j++] = uch;

    } else if (uch < 0x0800) {
      if (j >= ns-1) break;
      s[j++] = ((uch & 0x07C0) >>  6) | 0xC0;
      s[j++] =  (uch & 0x003F)        | 0x80;

    } else {
      if (j >= ns-2) break;
      s[j++] = ((uch & 0xF000) >> 12) | 0xE0;
      s[j++] = ((uch & 0x0FC0) >>  6) | 0x80;
      s[j++] =  (uch & 0x003F)        | 0x80;
    }
  }

  if (remaining)
    *remaining = nus - k;

  if (encoded)
    *encoded = j;
}

Here is the caller graph for this function:

int utf8toucs ( const char *  s,
int  ns,
UNICHAR us,
int  nus,
int  skipNUL,
int remaining,
int decoded 
)

Decodes UTF8 string S with NS characters to Unicode string US with upto NUS characters, returning the number of REMAINING Utf8 characters and the number of DECODED Unicode characters.

If skipNUL is non-zero, NUL input characters are skipped. returns 0 if successful, -1 if an error occurred during decoding

Definition at line 89 of file unistring.c.

{
  int j, k;
  int retcode = 0;

  j = 0;
  k = 0;
  while ((j < ns) && (k < nus)) {
    char ch = s[j];

    if (0x80 & ch) {
      if (0x40 & ch) {
        if (0x20 & ch) {
          /* consume 3 */
          if (j >= ns-2) break;

          if ( (s[j+1] & 0x40) || !(s[j+1] & 0x80) ||
               (s[j+2] & 0x40) || !(s[j+2] & 0x80) ) {
            retcode = -1;
          }

          us[k++] =   ((ch     & 0x0F) << 12)
                    | ((s[j+1] & 0x3F) << 6)
                    | ( s[j+2] & 0x3F);

          j += 3;

        } else {
          /* consume 2 */
          if (j >= ns-1) break;

          if ( (s[j+1] & 0x40) || !(s[j+1] & 0x80) ) {
            retcode = -1;
          }

          us[k++] =   ((ch     & 0x1F) << 6)
                    | ( s[j+1] & 0x3F);
          j += 2;
        }

      } else {
        /* consume 1 (error) */
        retcode = -1;
        j++;
      }

    } else {
      /* consume 1 */
      if (ch || !skipNUL) {
        us[k++] = ch;
      }
      j++;
    }
  }

  if (remaining)
    *remaining = ns - j;

  if (decoded)
    *decoded = k;

  return retcode;
}

Here is the caller graph for this function: