diff options
author | tsmith@maint1.mysql.com <> | 2007-06-21 18:58:31 +0200 |
---|---|---|
committer | tsmith@maint1.mysql.com <> | 2007-06-21 18:58:31 +0200 |
commit | 3ae37d30deddcae0deb34120350801f8a2c43d5e (patch) | |
tree | f2b8dc257630c43d5656c14d2fc4a352f295fc34 /mysys/charset.c | |
parent | 8e65f663788cd923b6a0dbd3b6537413c8e48d53 (diff) | |
parent | 7758a5de33727ce71f29903e62d3826570b3b842 (diff) | |
download | mariadb-git-3ae37d30deddcae0deb34120350801f8a2c43d5e.tar.gz |
Merge maint1.mysql.com:/data/localhome/tsmith/bk/51
into maint1.mysql.com:/data/localhome/tsmith/bk/maint/51
Diffstat (limited to 'mysys/charset.c')
-rw-r--r-- | mysys/charset.c | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/mysys/charset.c b/mysys/charset.c index c6065f87df3..5f9521eeab8 100644 --- a/mysys/charset.c +++ b/mysys/charset.c @@ -573,6 +573,70 @@ CHARSET_INFO *get_charset_by_csname(const char *cs_name, } +/** + Resolve character set by the character set name (utf8, latin1, ...). + + The function tries to resolve character set by the specified name. If + there is character set with the given name, it is assigned to the "cs" + parameter and FALSE is returned. If there is no such character set, + "default_cs" is assigned to the "cs" and TRUE is returned. + + @param[out] cs Variable to store character set. + @param[in] cs_name Character set name. + @param[in] default_cs Default character set. + + @return FALSE if character set was resolved successfully; TRUE if there + is no character set with given name. +*/ + +bool resolve_charset(CHARSET_INFO **cs, + const char *cs_name, + CHARSET_INFO *default_cs) +{ + *cs= get_charset_by_csname(cs_name, MY_CS_PRIMARY, MYF(0)); + + if (*cs == NULL) + { + *cs= default_cs; + return TRUE; + } + + return FALSE; +} + + +/** + Resolve collation by the collation name (utf8_general_ci, ...). + + The function tries to resolve collation by the specified name. If there + is collation with the given name, it is assigned to the "cl" parameter + and FALSE is returned. If there is no such collation, "default_cl" is + assigned to the "cl" and TRUE is returned. + + @param[out] cl Variable to store collation. + @param[in] cl_name Collation name. + @param[in] default_cl Default collation. + + @return FALSE if collation was resolved successfully; TRUE if there is no + collation with given name. +*/ + +bool resolve_collation(CHARSET_INFO **cl, + const char *cl_name, + CHARSET_INFO *default_cl) +{ + *cl= get_charset_by_name(cl_name, MYF(0)); + + if (*cl == NULL) + { + *cl= default_cl; + return TRUE; + } + + return FALSE; +} + + /* Escape string with backslashes (\) |