aboutsummaryrefslogtreecommitdiffstats
path: root/src/asn1_str.cpp
diff options
context:
space:
mode:
authorlloyd <[email protected]>2006-06-19 09:20:23 +0000
committerlloyd <[email protected]>2006-06-19 09:20:23 +0000
commit69ca3d65b82ab041e8df85ca3f4e63e669557607 (patch)
tree23005899d23998ada689d4babd2bfccb4d520dbe /src/asn1_str.cpp
parent6413b5d29a781a231d2f331e4191b68fb88a27d9 (diff)
Remove the to_lower function; turns out that both uses of it
within the library were to perform case-insensitive matching, so simply implement that instead. Place all of the character set handling functions into a Charset namespace (and update all callers). Remove the iso2local/local2iso/iso2utf/utf2iso functions, replaced by the new charset transcoder stuff. Initialize the transcoder stored in the global library state upon initialization.
Diffstat (limited to 'src/asn1_str.cpp')
-rw-r--r--src/asn1_str.cpp22
1 files changed, 15 insertions, 7 deletions
diff --git a/src/asn1_str.cpp b/src/asn1_str.cpp
index f3c8584ed..c67480267 100644
--- a/src/asn1_str.cpp
+++ b/src/asn1_str.cpp
@@ -73,7 +73,8 @@ bool is_string_type(ASN1_Tag tag)
*************************************************/
ASN1_String::ASN1_String(const std::string& str, ASN1_Tag t) : tag(t)
{
- iso_8859_str = local2iso(str);
+ iso_8859_str = Charset::transcode(str, LOCAL_CHARSET, LATIN1_CHARSET);
+
if(tag == DIRECTORY_STRING)
tag = choose_encoding(iso_8859_str);
@@ -93,7 +94,7 @@ ASN1_String::ASN1_String(const std::string& str, ASN1_Tag t) : tag(t)
*************************************************/
ASN1_String::ASN1_String(const std::string& str)
{
- iso_8859_str = local2iso(str);
+ iso_8859_str = Charset::transcode(str, LOCAL_CHARSET, LATIN1_CHARSET);
tag = choose_encoding(iso_8859_str);
}
@@ -110,7 +111,7 @@ std::string ASN1_String::iso_8859() const
*************************************************/
std::string ASN1_String::value() const
{
- return iso2local(iso_8859_str);
+ return Charset::transcode(iso_8859_str, LATIN1_CHARSET, LOCAL_CHARSET);
}
/*************************************************
@@ -128,7 +129,7 @@ void ASN1_String::encode_into(DER_Encoder& encoder) const
{
std::string value = iso_8859();
if(tagging() == UTF8_STRING)
- value = iso2utf(value);
+ value = Charset::transcode(value, LATIN1_CHARSET, UTF8_CHARSET);
encoder.add_object(tagging(), UNIVERSAL, value);
}
@@ -140,6 +141,7 @@ namespace {
// FIXME: inline this
std::string convert_string(BER_Object obj, ASN1_Tag type)
{
+ // FIMXE: add a UNC16_CHARSET transcoder op
if(type == BMP_STRING)
{
if(obj.value.size() % 2 == 1)
@@ -156,12 +158,18 @@ std::string convert_string(BER_Object obj, ASN1_Tag type)
value += (char)c2;
}
- return iso2local(value);
+ return Charset::transcode(value, LATIN1_CHARSET, LOCAL_CHARSET);
}
else if(type == UTF8_STRING)
- return iso2local(utf2iso(ASN1::to_string(obj)));
+ {
+ return Charset::transcode(ASN1::to_string(obj), UTF8_CHARSET,
+ LOCAL_CHARSET);
+ }
else
- return iso2local(ASN1::to_string(obj));
+ {
+ return Charset::transcode(ASN1::to_string(obj),
+ LATIN1_CHARSET, LOCAL_CHARSET);
+ }
}
}