diff options
author | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-07-06 08:51:53 +0300 |
---|---|---|
committer | Jaakko Keränen <jaakko.keranen@iki.fi> | 2021-07-06 08:51:53 +0300 |
commit | 7002917c07e8eca462391906ac1d3b2bcaf6b888 (patch) | |
tree | 30148d0d3f7d975d6fe1b07b16f047d2bb3b2c27 /src/gmdocument.c | |
parent | cfc05e4c4fdcbe35e15111ce52f5d73541533859 (diff) |
GmDocument: Ignore BOM if present
Diffstat (limited to 'src/gmdocument.c')
-rw-r--r-- | src/gmdocument.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/gmdocument.c b/src/gmdocument.c index d49cccd9..a46e71cf 100644 --- a/src/gmdocument.c +++ b/src/gmdocument.c | |||
@@ -1482,6 +1482,13 @@ iLocalDef iBool isNormalizableSpace_(char ch) { | |||
1482 | static void normalize_GmDocument(iGmDocument *d) { | 1482 | static void normalize_GmDocument(iGmDocument *d) { |
1483 | iString *normalized = new_String(); | 1483 | iString *normalized = new_String(); |
1484 | iRangecc src = range_String(&d->source); | 1484 | iRangecc src = range_String(&d->source); |
1485 | /* Check for a BOM. In UTF-8, the BOM can just be skipped if present. */ { | ||
1486 | iChar ch = 0; | ||
1487 | decodeBytes_MultibyteChar(src.start, src.end, &ch); | ||
1488 | if (ch == 0xfeff) /* zero-width non-breaking space */ { | ||
1489 | src.start += 3; | ||
1490 | } | ||
1491 | } | ||
1485 | iRangecc line = iNullRange; | 1492 | iRangecc line = iNullRange; |
1486 | iBool isPreformat = iFalse; | 1493 | iBool isPreformat = iFalse; |
1487 | if (d->format == plainText_SourceFormat) { | 1494 | if (d->format == plainText_SourceFormat) { |