|
On Tue, 16 Apr 2002, Jim Damato wrote: > > You can visually check the character set of the file by performing a WRKLNK > and checking attributes. I have no idea how to retrieve it > programmatically. Maybe there's an API? > I assume you mean "code page" rather than "character set". You can get the code page of a file in the IFS using the stat() API (one of the UNIX-type APIs) Here's a quickie example in RPG IV: H DFTACTGRP(*NO) BNDDIR('QC2LE') D statds DS D st_mode 10U 0 D st_ino 10U 0 D st_nlink 5U 0 D st_pad 2A D st_uid 10U 0 D st_gid 10U 0 D st_size 10I 0 D st_atime 10I 0 D st_mtime 10I 0 D st_ctime 10I 0 D st_dev 10U 0 D st_blksize 10U 0 D st_alctize 10U 0 D st_objtype 12A D st_codepage 5U 0 D st_resv11 62A D st_ino_gen_id 10U 0 D stat PR 10I 0 ExtProc('stat') D path * value options(*string) D buf * value D strerror PR * ExtProc('strerror') D errnum 10I 0 value D errno PR 10I 0 D filepath S 1024A D msg S 52A c eval *inlr = *on c eval filepath = '/home/klemscot/test.txt' c if stat(%trimr(filepath): %addr(statds)) < 0 c eval Msg = %str(strerror(errno)) c dsply msg c return c endif c eval Msg = 'codepage = ' + %editc(st_codepage:'M') c dsply msg c return P errno B D errno PI 10I 0 D @__errno PR * ExtProc('__errno') D p_errno S * D wwreturn S 10I 0 based(p_errno) C eval p_errno = @__errno c return wwreturn P E
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.