digitalmars.D.learn - how to get the \uxxxx unicode code from a char
- jicman (8/8) Oct 14 2014 Greetings.
- Sean Kelly (2/10) Oct 14 2014 I'd look at the JSON string encoder.
- jicman (3/17) Oct 14 2014 JSON? What does JSON has to do with my basic D? :-) No thanks.
- Brad Anderson (4/22) Oct 14 2014 Sean's saying that the JSON encoder does the same thing so you
- Brad Anderson (4/5) Oct 14 2014 Oops. Linked the the parser section. I actually don't see any
- Brad Anderson (5/11) Oct 14 2014 Here we go.
- jicman (3/16) Oct 14 2014 thanks. the problem is that I am still in D1. ;-) over 300K
- Sean Kelly (6/12) Oct 16 2014 Wow... the current std.json doesn't do string encoding? I knew
- ketmar via Digitalmars-d-learn (8/14) Oct 14 2014 On Tue, 14 Oct 2014 19:46:57 +0000
- jicman (4/21) Oct 14 2014 Thanks. This is a missing function in std.uni or std.string.
- =?UTF-8?B?QWxpIMOHZWhyZWxp?= (4/6) Oct 14 2014 I don't know D1 but there is std.utf.decode:
Greetings. Imagine this code, char[] s = "ABCabc"; foreach (char c; s) { // how do I convert c to something an Unicode code? ie. \u9999. } thanks.
Oct 14 2014
On Tuesday, 14 October 2014 at 19:47:00 UTC, jicman wrote:Greetings. Imagine this code, char[] s = "ABCabc"; foreach (char c; s) { // how do I convert c to something an Unicode code? ie. \u9999. }I'd look at the JSON string encoder.
Oct 14 2014
On Tuesday, 14 October 2014 at 19:49:16 UTC, Sean Kelly wrote:On Tuesday, 14 October 2014 at 19:47:00 UTC, jicman wrote:JSON? What does JSON has to do with my basic D? :-) No thanks. :-)Greetings. Imagine this code, char[] s = "ABCabc"; foreach (char c; s) { // how do I convert c to something an Unicode code? ie. \u9999. }I'd look at the JSON string encoder.
Oct 14 2014
On Tuesday, 14 October 2014 at 20:03:37 UTC, jicman wrote:On Tuesday, 14 October 2014 at 19:49:16 UTC, Sean Kelly wrote:Sean's saying that the JSON encoder does the same thing so you can look there for how to do it. https://github.com/D-Programming-Language/phobos/blob/master/std/json.d#L579On Tuesday, 14 October 2014 at 19:47:00 UTC, jicman wrote:JSON? What does JSON has to do with my basic D? :-) No thanks. :-)Greetings. Imagine this code, char[] s = "ABCabc"; foreach (char c; s) { // how do I convert c to something an Unicode code? ie. \u9999. }I'd look at the JSON string encoder.
Oct 14 2014
On Tuesday, 14 October 2014 at 20:05:07 UTC, Brad Anderson wrote:https://github.com/D-Programming-Language/phobos/blob/master/std/json.d#L579Oops. Linked the the parser section. I actually don't see any unicode escape encoder in here. Perhaps he meant the upcoming JSON module.
Oct 14 2014
On Tuesday, 14 October 2014 at 20:08:03 UTC, Brad Anderson wrote:On Tuesday, 14 October 2014 at 20:05:07 UTC, Brad Anderson wrote:Here we go. https://github.com/s-ludwig/std_data_json/blob/4ecb90626055269f4897902404741f1173fb5e8e/source/stdx/data/json/generator.d#L451 Sönke's is pretty sophisticated. You could probably just use the non-surrogate supporting simple branch.https://github.com/D-Programming-Language/phobos/blob/master/std/json.d#L579Oops. Linked the the parser section. I actually don't see any unicode escape encoder in here. Perhaps he meant the upcoming JSON module.
Oct 14 2014
On Tuesday, 14 October 2014 at 20:13:17 UTC, Brad Anderson wrote:On Tuesday, 14 October 2014 at 20:08:03 UTC, Brad Anderson wrote:thanks. the problem is that I am still in D1. ;-) over 300K lines of code and growing...On Tuesday, 14 October 2014 at 20:05:07 UTC, Brad Anderson wrote:Here we go. https://github.com/s-ludwig/std_data_json/blob/4ecb90626055269f4897902404741f1173fb5e8e/source/stdx/data/json/generator.d#L451 Sönke's is pretty sophisticated. You could probably just use the non-surrogate supporting simple branch.https://github.com/D-Programming-Language/phobos/blob/master/std/json.d#L579Oops. Linked the the parser section. I actually don't see any unicode escape encoder in here. Perhaps he meant the upcoming JSON module.
Oct 14 2014
On Tuesday, 14 October 2014 at 20:08:03 UTC, Brad Anderson wrote:On Tuesday, 14 October 2014 at 20:05:07 UTC, Brad Anderson wrote:Wow... the current std.json doesn't do string encoding? I knew it was bad, but... In any case, yes, I mentioned JSON because strings are supposed to be encoded exactly the way you're asking. It was easier to point at that than try to outline the process explicitly.https://github.com/D-Programming-Language/phobos/blob/master/std/json.d#L579Oops. Linked the the parser section. I actually don't see any unicode escape encoder in here. Perhaps he meant the upcoming JSON module.
Oct 16 2014
On Tue, 14 Oct 2014 19:46:57 +0000 jicman via Digitalmars-d-learn <digitalmars-d-learn puremagic.com> wrote:char[] s =3D "ABCabc"; foreach (char c; s) { // how do I convert c to something an Unicode code? ie. \u9999. =20 }string res; foreach (dchar ch; s) res ~=3D "\\u%04X".format(ch); // here we have the result in res note "dchar" instead of "char". with "dchar" foreach() does utf-8 decoding (as 's' is in utf-8).
Oct 14 2014
On Tuesday, 14 October 2014 at 19:56:29 UTC, ketmar via Digitalmars-d-learn wrote:On Tue, 14 Oct 2014 19:46:57 +0000 jicman via Digitalmars-d-learn <digitalmars-d-learn puremagic.com> wrote:Thanks. This is a missing function in std.uni or std.string. joséchar[] s = "ABCabc"; foreach (char c; s) { // how do I convert c to something an Unicode code? ie. \u9999. }string res; foreach (dchar ch; s) res ~= "\\u%04X".format(ch); // here we have the result in res note "dchar" instead of "char". with "dchar" foreach() does utf-8 decoding (as 's' is in utf-8).
Oct 14 2014