summaryrefslogtreecommitdiffstats
blob: 6b6c7a40a269e63d97640f18a44d201fcafb0e4d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
/*
 * 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 <cstdlib>
#include <idna.h>

namespace Swift {

std::string IDNA::getEncoded(const std::string& domain) {
	char* output;
	if (idna_to_ascii_8z(domain.c_str(), &output, 0) == IDNA_SUCCESS) {
		std::string result(output);
		free(output);
		return result;
	}
	else {
		return domain;
	}
}

}