www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Unicode in strings

reply Cecil Ward <cecil cecilward.com> writes:
How do I get a wstring or dstring with a code point of 0xA0 in it 
? That’s a type of space, is it? I keep getting a message from 
the LDC compiler something like "Outside Unicode code space" in 
my unittests when this is the first character in a wstring. I’ve 
tried all sorts of escape sequences but I must simply be 
misunderstanding the docs. I could always copy-paste a real live 
one into a double quoted string and be done with it, I suppose.
Jul 27 2023
next sibling parent "H. S. Teoh" <hsteoh qfbox.info> writes:
On Thu, Jul 27, 2023 at 10:15:47PM +0000, Cecil Ward via Digitalmars-d-learn
wrote:
 How do I get a wstring or dstring with a code point of 0xA0 in it ?
 That’s a type of space, is it? I keep getting a message from the LDC
 compiler something like "Outside Unicode code space" in my unittests
 when this is the first character in a wstring. I’ve tried all sorts of
 escape sequences but I must simply be misunderstanding the docs. I
 could always copy-paste a real live one into a double quoted string
 and be done with it, I suppose.
D strings are assumed to be encoded in UTF-8 / UTF-16 / UTF-32. So if you wrote something like `\xA0` in your string will likely generate an invalid encoding. Try instead `\u00A0`. T -- Ph.D. = Permanent head Damage
Jul 27 2023
prev sibling parent reply Adam D Ruppe <destructionator gmail.com> writes:
On Thursday, 27 July 2023 at 22:15:47 UTC, Cecil Ward wrote:
 How do I get a wstring or dstring with a code point of 0xA0 in 
 it ?
note that you don't need wstring and dstring to express all unicode strings.
Jul 27 2023
parent Cecil Ward <cecil cecilward.com> writes:
On Thursday, 27 July 2023 at 22:35:00 UTC, Adam D Ruppe wrote:
 On Thursday, 27 July 2023 at 22:15:47 UTC, Cecil Ward wrote:
 How do I get a wstring or dstring with a code point of 0xA0 in 
 it ?
note that you don't need wstring and dstring to express all unicode strings.
I realised that I was probably generating UTF8 and only one byte, so I switched to \u00A0, I think. Must have got that wrong too because I was still getting the error message. I’ll try it again carefully.
Jul 27 2023