std.encoding Usage

Mandeep Singh Brar mandeep at brars.co.in
Wed Jan 12 07:26:58 PST 2011


Putting here that the following worked for me.

string str
ubyte[] buffer;
foreach(ch;str) {
	ubyte[4] buf;
	int len = encodingScheme.encode(ch, buf);
	buffer~=buf[0..len];
}


ubyte[] encodedBuffer;
string decodedString;
while(encodedBuffer.length>0) {
decodedString~=cast(char)encodingScheme.safeDecode(encodedBuffer);
}

Thanks
Mandeep


More information about the Digitalmars-d-learn mailing list