digitalmars.D.learn - Error: unsupported char 0x03
- Agustin (18/18) Oct 22 2013 Trying to use mixin, i get an unsupported char error.
- Agustin (7/25) Oct 22 2013 protected template GenMessageGetId(uint id) {
- Adam D. Ruppe (10/12) Oct 22 2013 You'll probably want to convert id to a string there
- Agustin (2/14) Oct 22 2013 Works great, thanks! :)
- John Colvin (2/20) Oct 22 2013 do you perhaps want to!string(id) ???
- bearophile (5/6) Oct 22 2013 Or:
- Agustin (2/8) Oct 22 2013 I like id.text better than to!string, thanks
- =?UTF-8?B?QWxpIMOHZWhyZWxp?= (4/16) Oct 22 2013 Me too but the following looks nice too:
Trying to use mixin, i get an unsupported char error. protected template GenMessageGetId(uint id) { immutable string GenMessageGetId = "public immutable(int) getId() const { \n" ~ id ~ "; \n}"; } public mixin template Packet(uint id, T...) { ... private static string buildPacket() { ... return GenMessageGetId!(id); } mixin (buildPacket()); } class MyPacket : Message { mixin Packet!(3, ...); -> Error: unsupported char 0x03 } GenMessageGetId is generating "unsupported char 0x03".
Oct 22 2013
On Tuesday, 22 October 2013 at 15:01:20 UTC, Agustin wrote:Trying to use mixin, i get an unsupported char error. protected template GenMessageGetId(uint id) { immutable string GenMessageGetId = "public immutable(int) getId() const { \n" ~ id ~ "; \n}"; } public mixin template Packet(uint id, T...) { ... private static string buildPacket() { ... return GenMessageGetId!(id); } mixin (buildPacket()); } class MyPacket : Message { mixin Packet!(3, ...); -> Error: unsupported char 0x03 } GenMessageGetId is generating "unsupported char 0x03".protected template GenMessageGetId(uint id) { immutable string GenMessageGetId = "public immutable(int) getId() const { \nreturn" ~ id ~ "; \n}"; }
Oct 22 2013
On Tuesday, 22 October 2013 at 15:01:20 UTC, Agustin wrote:= "public immutable(int) getId() const { \n" ~ id ~ "; \n}";You'll probably want to convert id to a string there import std.conv; "public immutable(int) getId() const { \n" ~ to!string(id) ~ "; and also put in return for that function: "public immutable(int) getId() const { \n return " ~ to!string(id) ~ "; and it should compile. What was happening before is string ~ int implicitly converts the int to a char, and cast(char)(3) isn't a printable character, and isn't allowed in D source code.
Oct 22 2013
On Tuesday, 22 October 2013 at 15:05:16 UTC, Adam D. Ruppe wrote:On Tuesday, 22 October 2013 at 15:01:20 UTC, Agustin wrote:Works great, thanks! :)= "public immutable(int) getId() const { \n" ~ id ~ "; \n}";You'll probably want to convert id to a string there import std.conv; "public immutable(int) getId() const { \n" ~ to!string(id) ~ "; and also put in return for that function: "public immutable(int) getId() const { \n return " ~ to!string(id) ~ "; and it should compile. What was happening before is string ~ int implicitly converts the int to a char, and cast(char)(3) isn't a printable character, and isn't allowed in D source code.
Oct 22 2013
On Tuesday, 22 October 2013 at 15:01:20 UTC, Agustin wrote:Trying to use mixin, i get an unsupported char error. protected template GenMessageGetId(uint id) { immutable string GenMessageGetId = "public immutable(int) getId() const { \n" ~ id ~ "; \n}"; } public mixin template Packet(uint id, T...) { ... private static string buildPacket() { ... return GenMessageGetId!(id); } mixin (buildPacket()); } class MyPacket : Message { mixin Packet!(3, ...); -> Error: unsupported char 0x03 } GenMessageGetId is generating "unsupported char 0x03".do you perhaps want to!string(id) ???
Oct 22 2013
John Colvin:do you perhaps want to!string(id) ???Or: id.text Bye, bearophile
Oct 22 2013
On Tuesday, 22 October 2013 at 15:16:17 UTC, bearophile wrote:John Colvin:I like id.text better than to!string, thanksdo you perhaps want to!string(id) ???Or: id.text Bye, bearophile
Oct 22 2013
On 10/22/2013 08:56 AM, Agustin wrote:On Tuesday, 22 October 2013 at 15:16:17 UTC, bearophile wrote:Me too but the following looks nice too: id.to!string AliJohn Colvin:I like id.text better than to!string, thanksdo you perhaps want to!string(id) ???Or: id.text Bye, bearophile
Oct 22 2013