forums.silverfrost.com Forum Index forums.silverfrost.com
Welcome to the Silverfrost forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

MBConvertMBToUnicode

 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> General
View previous topic :: View next topic  
Author Message
StamK



Joined: 12 Oct 2016
Posts: 73

PostPosted: Fri Feb 01, 2019 3:26 pm    Post subject: MBConvertMBToUnicode Reply with quote

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
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 5683
Location: Salford, UK

PostPosted: Fri Feb 01, 2019 10:30 pm    Post subject: Reply with quote

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
View user's profile Send private message
StamK



Joined: 12 Oct 2016
Posts: 73

PostPosted: Sat Feb 02, 2019 1:44 am    Post subject: Reply with quote

Yes please! That would be fantastic...
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 5683
Location: Salford, UK

PostPosted: Sat Feb 02, 2019 11:31 am    Post subject: Reply with quote

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
View user's profile Send private message
John-Silver



Joined: 30 Jul 2013
Posts: 991
Location: Aerospace Valley

PostPosted: Sat Feb 02, 2019 6:07 pm    Post subject: Reply with quote

this would be a more appropriate message for it to print ....
Quote:
еще раз товарищ Павел вытаскивает кролика из шляпы! Smile

_________________
''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 ... Smile "
Back to top
View user's profile Send private message
StamK



Joined: 12 Oct 2016
Posts: 73

PostPosted: Mon Feb 04, 2019 1:46 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> General All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group