summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swiften/IDN/IDNA.cpp')
-rw-r--r--Swiften/IDN/IDNA.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/Swiften/IDN/IDNA.cpp b/Swiften/IDN/IDNA.cpp
new file mode 100644
index 0000000..a21ca63
--- /dev/null
+++ b/Swiften/IDN/IDNA.cpp
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2010 Remko Tronçon
+ * Licensed under the GNU General Public License v3.
+ * See Documentation/Licenses/GPLv3.txt for more information.
+ */
+
+#include "Swiften/IDN/IDNA.h"
+
+#include <stringprep.h>
+#include <vector>
+#include <idna.h>
+
+namespace Swift {
+
+String IDNA::getEncoded(const String& domain) {
+ char* output;
+ if (idna_to_ascii_8z(domain.getUTF8Data(), &output, 0) == IDNA_SUCCESS) {
+ String result(output);
+ free(output);
+ return result;
+ }
+ else {
+ return domain;
+ }
+}
+
+}