home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   alt.msdos.batch.nt      Fun with Windows NT batch files      68,980 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 67,336 of 68,980   
   Petr Laznovsky to All   
   For /F loop and Non-latin UTF-8 characte   
   24 Oct 18 14:17:02   
   
   From: nobody@nowhere.com   
      
   Have FOR /F loop which perform sqlite DB query and process its output.   
      
   for /f "tokens=*" %%a in ('echo %query% ^| %program%') do (echo %%a)   
      
   where %query% is:   
      
   SELECT icu_load_collation('cs_CZ', 'czech'); SELECT DISTINCT   
   customers.pid,customers.fname,customers.lname,customers.stnum,cu   
   tomers.flat_no,customers.city,customers.city_part,customers.mail   
   customers.tel,customers.status,customers.cust_type,customers.joi   
   _date,customers.leave_date,customers.fee,customers.varsym,   
   customers.note,customers.db_type,streets.st   
   FROM customers,streets WHERE NOT customers.status BETWEEN 4 AND 4 AND   
   customers.cust_type BETWEEN 1   
   AND 3 AND customers.lname LIKE '©%' AND streets.st_index = customers.st_index   
   ORDER BY lname;   
      
   and %program% is:   
      
   utilities\sqlite3shellicu.exe -separator "#$" "database\program.db"   
      
   The problem is, if the character before last AND statement ('©%' here) is   
   non-latin character, than   
   loop output nothing, in other words 'do' statement seem not perfored even once   
   (with ascii character   
   it work fine). Performing exact same query out of FOR /F loop give about 10   
   lines of output.   
   If FOR /F loop subject changed to not pipe string into sqlite program stdin,   
   but read it from file   
   in following manner:   
      
   for /f "tokens=*" %%a in ('%program% < query.txt') do (echo %%a)   
      
   than everything works fine with any character. Script itself is stored as   
   Unicode [pspad says:   
   "Unicode UTF-8 no BOM (65001)"], performing "CHCP 65001" just before the for   
   loop does not help.   
      
   Piping string into stdin instead of:   
      
   utilities\sqlite3shellicu.exe -separator "#$" "database\program.db"   
   "SELECT.....................;"   
      
   is because of this way criple non-ascii characters, as they are printed to   
   console window before   
   processing.   
      
   The script is part of larger set of scripts and all other script using piping   
   characters into sqlite   
   program stdin minimize disk IO operations, that is why I am try to arrange   
   this case by same way.   
      
      
   Anybody have idea?   
      
   L.   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca