Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
This community is designed for sharing of public information. Please do not share Intel or third-party confidential information here.
27159 Discussions

Print out UNICODE character using FORTRAN

Jing1
Novice
425 Views

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:
program WriteUNICODEChar

use, intrinsic :: iso_fortran_env, only: output_unit
implicit none

! Variables
integer, parameter :: u = selected_char_kind('ISO_10646')
character(kind=u, len=30) :: str

! Body of WriteUNICODEChar
print *, 'Hello World'
call sleep(3)

str = u_'Unicode character: \u263B'

open (output_unit, encoding='utf-8')
print '(a)', str

end program WriteUNICODEChar

 

0 Kudos
2 Replies
FortranFan
Honored Contributor II
406 Views

@Jing1 ,

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. 

jimdempseyatthecove
Black Belt
368 Views

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.

 

Jim Dempsey

Reply