Skip to content

Comments

Fix deprecation: std.utf.toUTF8 -> encode#5143

Merged
JackStouffer merged 1 commit intodlang:masterfrom
wilzbach:fix-deprecations
Feb 17, 2017
Merged

Fix deprecation: std.utf.toUTF8 -> encode#5143
JackStouffer merged 1 commit intodlang:masterfrom
wilzbach:fix-deprecations

Conversation

@wilzbach
Copy link
Contributor

@wilzbach wilzbach commented Feb 17, 2017

It seems like DMD doesn't like deprecating only one symbol. For selective imports it will always trigger a deprecation warning even if the symbol isn't used (issue 17193).

This PR fixes the deprecation warnings from toUTF8 on Posix. grep shows that there are more on Windows.

std/json.d Outdated
}
char[4] buf;
str.put(toUTF8(buf, val));
encode(buf, val);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

immutable len = encode(buf, val);
str.put(buf[0 .. len]);

std/uri.d Outdated
import std.utf : toUTF8;
// selective imports trigger wrong deprecation
// https://issues.dlang.org/show_bug.cgi?id=17193
import std.utf;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is going to trigger a failure in circle

std/json.d Outdated
{
import std.ascii : isWhite, isDigit, isHexDigit, toUpper, toLower;
import std.utf : toUTF8;
import std.utf : encode, Yes;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes is from std.typecons

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW any module using template flags is supposed to export Yes as well, so this is really personal preference or personal purism ;-)

std/stdio.d Outdated
auto b = toUTF8(buf, c);
foreach (i ; 0 .. b.length)
trustedFPUTC(b[i], handle_);
auto len = encode(buf, c);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

immutable

@JackStouffer
Copy link
Contributor

Auto-merge toggled on

@JackStouffer JackStouffer merged commit bf7e608 into dlang:master Feb 17, 2017
@wilzbach wilzbach deleted the fix-deprecations branch February 19, 2017 23:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants