2
2
// This file is part of the aMule Project.
4
// Copyright (c) 2004-2008 Angel Vidal Veiga - Kry (kry@amule.org)
5
// Copyright (c) 2003-2008 aMule Team ( admin@amule.org / http://www.amule.org )
4
// Copyright (c) 2004-2009 Angel Vidal Veiga - Kry (kry@amule.org)
5
// Copyright (c) 2003-2009 aMule Team ( admin@amule.org / http://www.amule.org )
7
7
// Any parts of this program derived from the xMule, lMule or eMule project,
8
8
// or contributed by third-party developers are copyrighted by their
34
34
#include <wx/uri.h> // Needed for wxURI
36
36
// Implementation of the non-inlines
39
// Backport da aMule SVN r9992 per client testuali e console non-UTF8
42
// Conversion of wxString so it can be used by printf() in a console
43
// On some platforms (Windows) the console allows only "plain" characters,
44
// so try to convert as much as possible and replace the others with '?'.
45
// On other platforms (some Linux) wxConvLocal silently converts to UTF8
46
// so the console can show even Chinese chars.
48
Unicode2CharBuf unicode2char(const wxChar* s)
50
// First try the straight way.
51
Unicode2CharBuf buf1(wxConvLocal.cWX2MB(s));
52
if ((const char *) buf1) {
55
// Failed. Try to convert as much as possible.
56
size_t len = wxStrlen(s);
57
size_t maxlen = len * 4; // Allow for an encoding of up to 4 byte per char.
58
wxCharBuffer buf(maxlen + 1); // This is wasteful, but the string is used temporary anyway.
59
char * data = buf.data();
60
for (size_t i = 0, pos = 0; i < len; i++) {
61
size_t len_char = wxConvLocal.FromWChar(data + pos, maxlen - pos, s + i, 1);
62
if (len_char != wxCONV_FAILED) {
64
} else if (pos < maxlen) {
37
74
static byte base16Chars[17] = "0123456789ABCDEF";
39
76
wxString URLEncode(const wxString& sIn)