TextEncoding: add Encode/Decode methods.

This replaces convert_from/to_utf8 in a way that doesn't leak memory.

Use the new method in StyledEdit.

Fixes #6252, #3065.
This commit is contained in:
Adrien Destugues
2016-09-25 23:16:19 +02:00
parent fbb725bbdc
commit 08e5249142
3 changed files with 182 additions and 20 deletions
+18 -2
View File
@@ -13,16 +13,32 @@
#include <stddef.h>
struct UConverter;
class TextEncoding
{
public:
TextEncoding(BString name);
TextEncoding(const char* data, size_t length);
BString GetName();
~TextEncoding();
status_t InitCheck();
BString GetName();
status_t Encode(const char* input, size_t& inputLength, char* output,
size_t& outputLength);
status_t Decode(const char* input, size_t& inputLength, char* output,
size_t& outputLength);
status_t Flush(char* output, size_t& outputLength);
private:
BString fName;
UConverter* fUtf8Converter;
UConverter* fConverter;
};
#endif /* !TEXTENCODING_H */
#endif /* TEXTENCODING_H */