View previous topic :: View next topic |
Author |
Message |
StamK
Joined: 12 Oct 2016 Posts: 73
|
Posted: Fri Feb 01, 2019 3:26 pm Post subject: MBConvertMBToUnicode |
|
|
Is there in silverfrost an intrinsic similar to MBConvertMBToUnicode (available in Intel Fortran)?
We need to pass a licence key as unicode to a C++ call which will then check if it is correct. The actual key is a string in Fortran but needs to be converted to unicode.
Thanks |
|
Back to top |
|
 |
PaulLaidler Site Admin

Joined: 21 Feb 2005 Posts: 5681 Location: Salford, UK
|
Posted: Fri Feb 01, 2019 10:30 pm Post subject: |
|
|
There is no FTN95 intrinsic as such but it should be possible to directly call the Microsoft API function MultiByteToWideChar. I can try to put together some illustrative code if you need it. |
|
Back to top |
|
 |
StamK
Joined: 12 Oct 2016 Posts: 73
|
Posted: Sat Feb 02, 2019 1:44 am Post subject: |
|
|
Yes please! That would be fantastic... |
|
Back to top |
|
 |
PaulLaidler Site Admin

Joined: 21 Feb 2005 Posts: 5681 Location: Salford, UK
|
Posted: Sat Feb 02, 2019 11:31 am Post subject: |
|
|
Here is some sample code. The code page (CP_UTF8) and flag (MB_PRECOMPOSED) will depend on your context. The file was saved using Plato with "Advanced Save Options" as "UNICODE(UTF-8 without signature)".
The text says "Hello World" in Russian.
Code: | PROGRAM main
STDCALL MultiByteToWideChar 'MultiByteToWideChar'(VAL,VAL,STRING,VAL,REF,VAL):INTEGER*4
INTEGER count
INTEGER,PARAMETER::CP_UTF8=65001,MB_PRECOMPOSED=1,NCHARS=256
CHARACTER(NCHARS) str
INTEGER*2 wstr(NCHARS)
str = "Привет, мир"
!str = "Hello World"
count = MultiByteToWideChar(CP_UTF8,MB_PRECOMPOSED,str,LEN_TRIM(str),wstr,NCHARS)
DO i = 1,count
WRITE(*, '(Z6)') wstr(i)
END DO
END PROGRAM main |
|
|
Back to top |
|
 |
John-Silver

Joined: 30 Jul 2013 Posts: 991 Location: Aerospace Valley
|
Posted: Sat Feb 02, 2019 6:07 pm Post subject: |
|
|
this would be a more appropriate message for it to print ....
Quote: | еще раз товарищ Павел вытаскивает кролика из шляпы! |
_________________ ''Computers are incredibly rigid. They question nothing. Especialy input data.Human beings are incredibly trusting of computers and don't check input data. Together they are capable of cocking up even the simplest calculation ... " |
|
Back to top |
|
 |
StamK
Joined: 12 Oct 2016 Posts: 73
|
Posted: Mon Feb 04, 2019 1:46 pm Post subject: |
|
|
Many thanks for that Paul.
Unfortunately the third party C++ DLL doesn't seem to recognise the key passed this way. But I was able to pass it using a STRING keyword with STDCALL, so it wasn't necessary to use the conversion. In their help for Fortran they do say that is is necessary to convert first (for Intel Fortran), so I guess there is no need with Sivlerfrost! |
|
Back to top |
|
 |
|