I have a normal FB STRING that has been loaded with the contents of a JPEG file. When I set a DWSTRING = FB STRING the resulting DWSTRING is only 4 bytes long. Some code below. I have verified that sFileContents does have the contents of the JPEG file.
DIM sImageStream AS DWSTRING
DIM sFileContents AS STRING
' Get File Size
uImageAttributes.ImageSize = oCFileSys.GetFileSize(szImageFile)
' Get Raw Stream
sFileContents = STRING(uImageAttributes.ImageSize, 0)
hFile = CreateFileW(@szImageFile, GENERIC_READ, FILE_SHARE_READ, NULL, _
OPEN_EXISTING, FILE_FLAG_SEQUENTIAL_SCAN, NULL)
ReadFile(hFile, STRPTR(sFileContents), uImageAttributes.ImageSize, @dwBytesRead, NULL)
CloseHandle(hFile)
' Save Image for reference
sImageStream = sFileContents
Never use DWSTRING or any other null-terminated string (WSTRING, ZSTRING) to store binary data. For that, use STRING or a buffer of bytes.
It does not make any sense to convert the contents of a JPEG file to Unicode.