digitalmars.D.learn - Iterate over a string to get unicode codes
- Flamaros (2/2) Sep 01 2013 Is there a simple way to extract from a string all Unicode codes
- Adam D. Ruppe (6/8) Sep 01 2013 string foo = "whatever";
- Jos van Uden (7/14) Sep 01 2013 Or, if you prefer one-liners.
- Flamaros (2/10) Sep 01 2013 Thx, it's easier than I thought.
Is there a simple way to extract from a string all Unicode codes as uint values?
Sep 01 2013
On Sunday, 1 September 2013 at 14:07:00 UTC, Flamaros wrote:Is there a simple way to extract from a string all Unicode codes as uint values?string foo = "whatever"; foreach(dchar ch; foo) { // ch is the code point as a 32 bit number // use it directly or cast to uint here }
Sep 01 2013
On 1-9-2013 16:11, Adam D. Ruppe wrote:On Sunday, 1 September 2013 at 14:07:00 UTC, Flamaros wrote:Or, if you prefer one-liners. import std.stdio, std.string, std.conv; void main() { auto s = "\u00A0\u2345\u7865"; dtext(s).representation.writeln; }Is there a simple way to extract from a string all Unicode codes as uint values?string foo = "whatever"; foreach(dchar ch; foo) { // ch is the code point as a 32 bit number // use it directly or cast to uint here }
Sep 01 2013
On Sunday, 1 September 2013 at 14:11:54 UTC, Adam D. Ruppe wrote:On Sunday, 1 September 2013 at 14:07:00 UTC, Flamaros wrote:Thx, it's easier than I thought.Is there a simple way to extract from a string all Unicode codes as uint values?string foo = "whatever"; foreach(dchar ch; foo) { // ch is the code point as a 32 bit number // use it directly or cast to uint here }
Sep 01 2013