mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-09-05 17:44:55 -06:00
CtrlLib: TextCtrl::Load further optimized
git-svn-id: svn://ultimatepp.org/upp/trunk@6616 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
ca57f97f91
commit
7188602d1f
1 changed files with 16 additions and 4 deletions
|
|
@ -101,18 +101,30 @@ int TextCtrl::Load(Stream& s, byte charset) {
|
|||
charset = CHARSET_UTF8;
|
||||
}
|
||||
bool cr = false;
|
||||
byte b8 = 0;
|
||||
while(!s.IsEof()) {
|
||||
int c = s.Get();
|
||||
if(c == '\r')
|
||||
cr = true;
|
||||
if(c == '\n') {
|
||||
WString w = ToUnicode(~ln, ln.GetCount(), charset);
|
||||
line.Add(w);
|
||||
total += w.GetLength() + 1;
|
||||
if(b8 & 128) { // There are some chars > 127, need to convert
|
||||
WString w = ToUnicode(~ln, ln.GetCount(), charset);
|
||||
line.Add(w);
|
||||
total += w.GetLength() + 1;
|
||||
}
|
||||
else {
|
||||
total += ln.GetCount() + 1;
|
||||
Ln& l = line.Add();
|
||||
l.len = ln.GetCount();
|
||||
l.text = ln;
|
||||
}
|
||||
ln.Clear();
|
||||
b8 = 0;
|
||||
}
|
||||
if(c >= ' ' || c == '\t')
|
||||
if(c >= ' ' || c == '\t') {
|
||||
b8 |= c;
|
||||
ln.Cat(c);
|
||||
}
|
||||
}
|
||||
WString w = ToUnicode(~ln, ln.GetCount(), charset);
|
||||
line.Add(w);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue