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