From d634aed027512e084a7d8af9e02674cc8738d043 Mon Sep 17 00:00:00 2001 From: Vadim Lopatin Date: Mon, 19 Jan 2015 16:24:58 +0300 Subject: [PATCH] fix loading of text files w/o BOM --- src/dlangui/core/linestream.d | 8 ++++---- src/dlangui/platforms/sdl/sdlapp.d | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/dlangui/core/linestream.d b/src/dlangui/core/linestream.d index d892062b..df5c2269 100644 --- a/src/dlangui/core/linestream.d +++ b/src/dlangui/core/linestream.d @@ -488,7 +488,7 @@ class LineStream { uint len = cast(uint)stream.read(buf); LineStream res = null; if (buf[0] == 0xEF && buf[1] == 0xBB && buf[2] == 0xBF) { - res = new Utf8LineStream(stream, filename, buf, len); + res = new Utf8LineStream(stream, filename, buf, len, 3); } else if (buf[0] == 0x00 && buf[1] == 0x00 && buf[2] == 0xFE && buf[3] == 0xFF) { res = new Utf32beLineStream(stream, filename, buf, len); } else if (buf[0] == 0xFF && buf[1] == 0xFE && buf[2] == 0x00 && buf[3] == 0x00) { @@ -502,7 +502,7 @@ class LineStream { res._bomDetected = true; } else { if (autodetectUTFIfNoBOM) { - res = new Utf8LineStream(stream, filename, buf, len); + res = new Utf8LineStream(stream, filename, buf, len, 0); } else { res = new AsciiLineStream(stream, filename, buf, len); } @@ -552,8 +552,8 @@ private class AsciiLineStream : LineStream { } private class Utf8LineStream : LineStream { - this(InputStream stream, string filename, ubyte[] buf, uint len) { - super(stream, filename, EncodingType.UTF8, buf, 3, len); + this(InputStream stream, string filename, ubyte[] buf, uint len, int skip) { + super(stream, filename, EncodingType.UTF8, buf, skip, len); } override uint decodeText() { if (invalidCharFlag) { diff --git a/src/dlangui/platforms/sdl/sdlapp.d b/src/dlangui/platforms/sdl/sdlapp.d index 20001218..8657da01 100644 --- a/src/dlangui/platforms/sdl/sdlapp.d +++ b/src/dlangui/platforms/sdl/sdlapp.d @@ -115,7 +115,7 @@ class SDLWindow : Window { _glSupport = new GLSupport(); } _win = SDL_CreateWindow(toUTF8(_caption).toStringz, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, - 700, 500, + 800, 600, windowFlags); version(USE_OPENGL) { if (!_win) { @@ -125,7 +125,7 @@ class SDLWindow : Window { // recreate w/o OpenGL windowFlags &= ~SDL_WINDOW_OPENGL; _win = SDL_CreateWindow(toUTF8(_caption).toStringz, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, - 700, 500, + 800, 600, windowFlags); } }