Fix charset detection and conversion issues

This commit is contained in:
Pierre Jeanjean 2020-02-02 15:37:05 +01:00 committed by odrling
parent 8165f1ad5e
commit 1ad2d838ad
No known key found for this signature in database
GPG Key ID: EC907F69A27A90C5
2 changed files with 4 additions and 2 deletions

View File

@ -22,7 +22,6 @@ namespace agi {
line_iterator_base::line_iterator_base(std::istream &stream, std::string encoding)
: stream(&stream)
{
boost::to_lower(encoding);
if (encoding != "utf-8") {
agi::charset::IconvWrapper c("utf-8", encoding.c_str());
c.Convert("\r", 1, reinterpret_cast<char *>(&cr), sizeof(int));

View File

@ -47,8 +47,11 @@ namespace CharSetDetect {
std::string GetEncoding(agi::fs::path const& filename) {
auto encoding = agi::charset::Detect(filename);
if (!encoding.empty())
if (!encoding.empty()) {
if (!encoding.compare("ASCII") || !encoding.compare("UTF-8"))
encoding = "utf-8";
return encoding;
}
auto choices = agi::charset::GetEncodingsList<wxArrayString>();
int choice = wxGetSingleChoiceIndex(