BBC BASIC for Windows
« Reading unicode filenames »

Welcome Guest. Please Login or Register.
Apr 5th, 2018, 9:54pm



ATTENTION MEMBERS: Conforums will be closing it doors and discontinuing its service on April 15, 2018.
Ad-Free has been deactivated. Outstanding Ad-Free credits will be reimbursed to respective payment methods.

If you require a dump of the post on your message board, please come to the support board and request it.


Thank you Conforums members.

BBC BASIC for Windows Resources
Online BBC BASIC for Windows documentation
BBC BASIC for Windows Beginners' Tutorial
BBC BASIC Home Page
BBC BASIC on Rosetta Code
BBC BASIC discussion group
BBC BASIC for Windows Programmers' Reference

« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 thread  Author  Topic: Reading unicode filenames  (Read 822 times)
southwest
New Member
Image


member is offline

Avatar




Homepage PM

Gender: Male
Posts: 2
question Reading unicode filenames
« Thread started on: Aug 30th, 2014, 9:30pm »

I'm trying to write a utility to convert utf-8 chars in filenames into their nearest ANSI equivalent, as well as shortening long filenames etc.

When I try to read filenames with the standard SYS FindFirstFile program, unusual chars come out as question marks. *Spool-ing *Dir produces the same result. A rummaging through Google suggests I should be using FindFirstFileW and similar calls, but nothing at all comes back from this.
User IP Logged

rtr2
Guest
question Re: Reading unicode filenames
« Reply #1 on: Aug 30th, 2014, 9:55pm »

on Aug 30th, 2014, 9:30pm, southwest wrote:
Google suggests I should be using FindFirstFileW and similar calls, but nothing at all comes back from this.

FindFirstFileW works for me:

Code:
      CP_UTF8 = &FDE9
      VDU 23,22,640;512;8,16,16,128+8 : REM Select UTF-8 mode
      *font Courier New
      PROClistdirectory_utf8
      END

      DEF PROClistdirectory_utf8
      LOCAL dir%, sh%, res%, utf8%
      DIM dir% LOCAL 317, utf8% LOCAL 260
      SYS "FindFirstFileW", "*"+CHR$0+CHR$0, dir% TO sh%
      IF sh% <> -1 THEN
        REPEAT
          SYS "WideCharToMultiByte", CP_UTF8, 0, dir%+44, -1, utf8%, 260, 0, 0
          PRINT $$utf8%
          SYS "FindNextFileW", sh%, dir% TO res%
        UNTIL res% = 0
        SYS "FindClose", sh%
      ENDIF
      ENDPROC 

User IP Logged

southwest
New Member
Image


member is offline

Avatar




Homepage PM

Gender: Male
Posts: 2
question Re: Reading unicode filenames
« Reply #2 on: Aug 30th, 2014, 10:09pm »

Interesting.

I thought the SYS/API parameters were identical from the C examples I could find,
I suspected they were not, but further searching proved fruitless.

Thanks for pointing me in the right direction.
« Last Edit: Aug 30th, 2014, 10:09pm by southwest » User IP Logged

Pages: 1  Notify Send Topic Print
« Previous Topic | Next Topic »

| |

This forum powered for FREE by Conforums ©
Terms of Service | Privacy Policy | Conforums Support | Parental Controls