We are trying to print out UNICODE character using FORTRAN. We wrote a test code, but couldn't compile. Do you know what's wrong or can you please send us some sample code for print out UNICODE character? Thanks.
Here is our test code:
use, intrinsic :: iso_fortran_env, only: output_unit
integer, parameter :: u = selected_char_kind('ISO_10646')
character(kind=u, len=30) :: str
! Body of WriteUNICODEChar
print *, 'Hello World'
str = u_'Unicode character: \u263B'
open (output_unit, encoding='utf-8')
print '(a)', str
end program WriteUNICODEChar
Intel Fortran does not support `selected_char_kind('ISO_10646')` - note the ISO IEC standard for Fortran does not require a processor to support this character set - it's like an optional thingy. However there are other Fortran compilers which do extend such support and the code you post will work alright with them. So you can either try another Fortran processor, or submit a request with Intel at their support center: https://supporttickets.intel.com/servicecenter?lang=en-US and they may follow up on your request and include this in their IFORT (and possibly IFX) product at some point in the future.
You can get to where you need to be by using the C interoperable ability to call UNICODE supported routines written in C/C++/C#/Pascal/...
While it may be annoying to not be able to hold your literals together with you code, it is not all that unreasonable either. Though you will have to replace your PRINT statements with a function call or subroutine.
Consider you wishing to use multi-language support using both ANSI and multiple UNICODE languages. For this, one typically uses multiple tables with enumerated offsets (enum'd) and the specific table is selected at installation and/or at runtime.