aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlloyd <[email protected]>2006-06-19 09:30:24 +0000
committerlloyd <[email protected]>2006-06-19 09:30:24 +0000
commit93f89be401584e25a1ce182ac5f0bd6b2cab947f (patch)
tree92cfcdb77115adc16bd0f679108d47aa8a527e8e
parent87e6643958a0da9541ba774a2f91122a16ff3d06 (diff)
Clean up convert_string to use the transcoding operation always
-rw-r--r--src/asn1_str.cpp34
1 files changed, 8 insertions, 26 deletions
diff --git a/src/asn1_str.cpp b/src/asn1_str.cpp
index c67480267..3d1233b6b 100644
--- a/src/asn1_str.cpp
+++ b/src/asn1_str.cpp
@@ -141,35 +141,17 @@ 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)
- throw BER_Decoding_Error("BMP STRING has an odd number of bytes");
-
- std::string value;
- for(u32bit j = 0; j != obj.value.size(); j += 2)
- {
- const byte c1 = obj.value[j];
- const byte c2 = obj.value[j+1];
-
- if(c1 != 0)
- throw BER_Decoding_Error("BMP STRING has non-Latin1 characters");
+ Character_Set charset_is;
- value += (char)c2;
- }
- return Charset::transcode(value, LATIN1_CHARSET, LOCAL_CHARSET);
- }
+ if(type == BMP_STRING)
+ charset_is = UCS2_CHARSET;
else if(type == UTF8_STRING)
- {
- return Charset::transcode(ASN1::to_string(obj), UTF8_CHARSET,
- LOCAL_CHARSET);
- }
+ charset_is = UTF8_CHARSET;
else
- {
- return Charset::transcode(ASN1::to_string(obj),
- LATIN1_CHARSET, LOCAL_CHARSET);
- }
+ charset_is = LATIN1_CHARSET;
+
+ return Charset::transcode(ASN1::to_string(obj),
+ charset_is, LOCAL_CHARSET);
}
}