'Image as Text on different languages for Non-Unicode programs

A multi user program, written in VB6, saves scanned pictures and shows/displays them on Image control. Users can scan pictures and same and/or other users can view them. Pictures are saved in a Text column (datatype = Text) of SQL Server. Saving and showing pictures works fine as long as Control Panel -> Region -> Administrative -> Language for non-Unicode programs (say non-uni-lang) is English (United States) or probably the same on both scanners' and viewers' PCs.

When viewers' non-uni-lang is different then they can't view pictures, pictures get corrupted.

I have noticed that the Recordset receives different data/text on machines with different non-uni-lang. Base64 equivalent of the saved Text is same on PCs with different non-uni-lang but decoding them back to binary differs.

GetACP API can be used to get the value but i couldn't find any API to change the value. There is a registry key but it requires reboot to have effect.

Questions:

  1. Is there any way to change non-uni-lang?
  2. Is there any way, independent of non-uni-lang, to decode base64 back to binary?

Edit 1 Base64 Encoding

select cast('' as xml).value('xs:base64Binary(sql:column("mytext"))', 'nvarchar(max)') from (
    select CAST(mytext AS varbinary(MAX)) mytext from (
        select CAST(ImageData AS nvarchar(MAX)) mytext from ImageTable where ImageID = 123
    ) t2
) t1

Base64 Decoding (Code by CVMichael) https://www.vbforums.com/showthread.php?197891-CryptBinaryToString-(new-BASE-64-function-so-RESOLVED)&p=1166849#post1166849

Edit 2

Eliminated SQL Server. I copied base64 string in a text file, read it as byte array in vb6, decoded and made multiple conversions and it showed the image on English PC but failed on Arabic PC. Please download the working code from https://drive.google.com/file/d/1Jv0ELXvxhd9E0V6RhiqrexVyiunG9UE1/view?usp=sharing



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source