[fpc-pascal] Read lines into UnicodeString variable from UCS2 (UTF-16) encoded text file

DougC doug at moosemail.net
Mon Sep 16 00:29:22 CEST 2019


Tomas-



Thanks for pursuing this! Generally a good approach.



I do not like item 3 in that the function, as described, is named DetectUtfBom but does more than detect. Side effects of functions are generally not good. I would at least rename it something like DetectAndHandleUtfBom.



But to fully correct the situation, I would also change it to a procedure since leaving it as a function still suggests it only returns a result and has no other side effects.



Doug C.



---- On Sun, 15 Sep 2019 18:20:22 -0400 Tomas Hajny <XHajT03 at hajny.biz> wrote ----


3) New function 'DetectUtfBom (var T: text): boolean' will be added. 
This function may be called after the call to 'Reset (T: text)' to check 
for existence of BOM at the beginning of the text file. If it is found 
(Result=true), SetTextCodePage is invoked automatically from 
DetectUtfBom with the codepage value corresponding to the found BOM and 
encoding variant. If BOM is not found (Result=false), nothing changes.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20190915/37a553c5/attachment.html>


More information about the fpc-pascal mailing list