mirror of https://github.com/buggins/dlangui.git
fix toUTF8 deprecation
This commit is contained in:
parent
90f6967dda
commit
f5b00be79c
|
@ -24,7 +24,7 @@ private import dlangui.widgets.widget;
|
||||||
|
|
||||||
private import std.string;
|
private import std.string;
|
||||||
private import std.conv;
|
private import std.conv;
|
||||||
private import std.utf;
|
private import std.utf : toUTF32;
|
||||||
|
|
||||||
/// Keyboard accelerator (key + modifiers)
|
/// Keyboard accelerator (key + modifiers)
|
||||||
struct Accelerator {
|
struct Accelerator {
|
||||||
|
|
|
@ -425,7 +425,7 @@ RootEntry[] getBookmarkPaths() nothrow
|
||||||
|
|
||||||
import core.stdc.wchar_ : wcslen;
|
import core.stdc.wchar_ : wcslen;
|
||||||
import std.exception : enforce;
|
import std.exception : enforce;
|
||||||
import std.utf : toUTF8, toUTF16z;
|
import std.utf : toUTF16z;
|
||||||
import std.file : dirEntries, SpanMode;
|
import std.file : dirEntries, SpanMode;
|
||||||
import std.string : endsWith;
|
import std.string : endsWith;
|
||||||
|
|
||||||
|
|
|
@ -65,7 +65,7 @@ import dlangui.core.logger;
|
||||||
import dlangui.core.files;
|
import dlangui.core.files;
|
||||||
import dlangui.graphics.resources;
|
import dlangui.graphics.resources;
|
||||||
private import dlangui.core.linestream;
|
private import dlangui.core.linestream;
|
||||||
private import std.utf;
|
private import std.utf : toUTF32;
|
||||||
private import std.algorithm;
|
private import std.algorithm;
|
||||||
private import std.string;
|
private import std.string;
|
||||||
private import std.file;
|
private import std.file;
|
||||||
|
|
|
@ -519,3 +519,15 @@ uint parseHexDigit(T)(T ch) pure nothrow {
|
||||||
return ch - 'A' + 10;
|
return ch - 'A' + 10;
|
||||||
return uint.max;
|
return uint.max;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// replacement of deprecated std.utf.toUTF8
|
||||||
|
string toUTF8(dstring str) {
|
||||||
|
import std.utf : encode, codeLength, byUTF;
|
||||||
|
char[] buf;
|
||||||
|
buf.length = codeLength!char(str);
|
||||||
|
int pos = 0;
|
||||||
|
foreach(ch; str.byUTF!char) {
|
||||||
|
buf.ptr[pos++] = ch;
|
||||||
|
}
|
||||||
|
return cast(string)buf;
|
||||||
|
}
|
||||||
|
|
|
@ -41,7 +41,7 @@ import dlangui.dialogs.dialog;
|
||||||
private import std.algorithm;
|
private import std.algorithm;
|
||||||
private import std.file;
|
private import std.file;
|
||||||
private import std.path;
|
private import std.path;
|
||||||
private import std.utf;
|
private import std.utf : toUTF32;
|
||||||
private import std.string;
|
private import std.string;
|
||||||
private import std.array;
|
private import std.array;
|
||||||
private import std.conv : to;
|
private import std.conv : to;
|
||||||
|
|
|
@ -19,7 +19,7 @@ import dlangui.dialogs.dialog;
|
||||||
private import std.algorithm;
|
private import std.algorithm;
|
||||||
private import std.file;
|
private import std.file;
|
||||||
private import std.path;
|
private import std.path;
|
||||||
private import std.utf;
|
private import std.utf : toUTF32;
|
||||||
private import std.conv : to;
|
private import std.conv : to;
|
||||||
private import std.array : split;
|
private import std.array : split;
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,7 @@ import dlangui.widgets.widget;
|
||||||
import dlangui.widgets.metadata;
|
import dlangui.widgets.metadata;
|
||||||
import std.conv : to;
|
import std.conv : to;
|
||||||
import std.algorithm : equal, min, max;
|
import std.algorithm : equal, min, max;
|
||||||
import std.utf : toUTF32, toUTF8;
|
import std.utf : toUTF32;
|
||||||
import std.array : join;
|
import std.array : join;
|
||||||
public import dlangui.dml.annotations;
|
public import dlangui.dml.annotations;
|
||||||
public import dlangui.dml.tokenizer;
|
public import dlangui.dml.tokenizer;
|
||||||
|
|
|
@ -4,7 +4,7 @@ import dlangui.core.types;
|
||||||
import dlangui.core.linestream;
|
import dlangui.core.linestream;
|
||||||
|
|
||||||
import std.conv : to;
|
import std.conv : to;
|
||||||
import std.utf : toUTF32, toUTF8;
|
import std.utf : toUTF32;
|
||||||
import std.algorithm : equal, min, max;
|
import std.algorithm : equal, min, max;
|
||||||
|
|
||||||
enum TokenType : ushort {
|
enum TokenType : ushort {
|
||||||
|
@ -450,7 +450,7 @@ class Tokenizer {
|
||||||
}
|
}
|
||||||
|
|
||||||
string getContextSource() {
|
string getContextSource() {
|
||||||
string s = toUTF8(_lineText);
|
string s = toUTF8(cast(dstring)_lineText);
|
||||||
if (_pos == 0)
|
if (_pos == 0)
|
||||||
return " near `^^^" ~ s[0..min($,30)] ~ "`";
|
return " near `^^^" ~ s[0..min($,30)] ~ "`";
|
||||||
if (_pos >= _len)
|
if (_pos >= _len)
|
||||||
|
|
|
@ -83,5 +83,5 @@ public {
|
||||||
// some useful imports from Phobos
|
// some useful imports from Phobos
|
||||||
import std.algorithm : equal;
|
import std.algorithm : equal;
|
||||||
import std.conv : to;
|
import std.conv : to;
|
||||||
import std.utf : toUTF32, toUTF8;
|
import std.utf : toUTF32;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue