branches/zip: Add the function dtype_is_utf8().

This commit is contained in:
marko 2007-10-25 07:19:43 +00:00
parent bde9d122ad
commit dd7f702117
2 changed files with 35 additions and 0 deletions

View file

@ -275,6 +275,16 @@ dtype_form_prtype(
DATA_BINARY_TYPE etc. */
ulint charset_coll); /* in: MySQL charset-collation code */
/*************************************************************************
Determines if a MySQL string type is a subset of UTF-8. This function
may return false negatives, in case further character-set collation
codes are introduced in MySQL later. */
UNIV_INLINE
ibool
dtype_is_utf8(
/*==========*/
/* out: TRUE if a subset of UTF-8 */
ulint prtype);/* in: precise data type */
/*************************************************************************
Gets the type length. */
UNIV_INLINE
ulint

View file

@ -34,6 +34,31 @@ dtype_get_charset_coll(
return((prtype >> 16) & 0xFFUL);
}
/*************************************************************************
Determines if a MySQL string type is a subset of UTF-8. This function
may return false negatives, in case further character-set collation
codes are introduced in MySQL later. */
UNIV_INLINE
ibool
dtype_is_utf8(
/*==========*/
/* out: TRUE if a subset of UTF-8 */
ulint prtype) /* in: precise data type */
{
/* These codes have been copied from strings/ctype-extra.c
and strings/ctype-utf8.c. */
switch (dtype_get_charset_coll(prtype)) {
case 11: /* ascii_general_ci */
case 65: /* ascii_bin */
case 33: /* utf8_general_ci */
case 83: /* utf8_bin */
case 254: /* utf8_general_cs */
return(TRUE);
}
return(FALSE);
}
/*************************************************************************
Gets the MySQL type code from a dtype. */
UNIV_INLINE