aboutsummaryrefslogtreecommitdiffstats
path: root/src/charset.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/charset.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/charset.cpp')
-rw-r--r--src/charset.cpp34
1 files changed, 16 insertions, 18 deletions
diff --git a/src/charset.cpp b/src/charset.cpp
index 7aeccaf98..3a28cce92 100644
--- a/src/charset.cpp
+++ b/src/charset.cpp
@@ -6,10 +6,22 @@
#include <botan/charset.h>
#include <botan/hex.h>
#include <botan/base64.h>
+#include <botan/libstate.h>
#include <ctype.h>
namespace Botan {
+namespace Charset {
+
+/*************************************************
+* Perform character set transcoding *
+*************************************************/
+std::string transcode(const std::string& str,
+ Character_Set to, Character_Set from)
+ {
+ return global_state().transcode(str, to, from);
+ }
+
/*************************************************
* Check if a character represents a digit *
*************************************************/
@@ -70,28 +82,14 @@ char digit2char(byte b)
}
/*************************************************
-* Return the lower-case representation *
-*************************************************/
-char to_lower(char c)
- {
- return tolower((unsigned char)c);
- }
-
-/*************************************************
-* Convert from local charset to ISO 8859-1 *
+* Case-insensitive character comparison *
*************************************************/
-std::string local2iso(const std::string& str)
+bool caseless_cmp(char a, char b)
{
- return str;
+ return (tolower((unsigned char)a) == tolower((unsigned char)b));
}
-/*************************************************
-* Convert from ISO 8859-1 to local charset *
-*************************************************/
-std::string iso2local(const std::string& str)
- {
- return str;
- }
+}
/*************************************************
* Hex Encoder Lookup Tables *