<div>Hi!</div><div><br /></div><div>(</div><div><br /></div><div>> <span style="font-family:'calibri' , 'helvetica' , sans-serif;font-size:12pt">bytes < 0x80</span></div><div><br /></div><div> It's only 7bits ASCII English language text.</div><div>How about Latin-1? Russian? Greek?</div><div><br /></div><div>)</div><div><br /></div><div>> <span style="font-family:'calibri' , 'helvetica' , sans-serif;font-size:12pt">CreateFileW</span></div><div><span style="font-family:'calibri' , 'helvetica' , sans-serif;font-size:12pt"><br /></span></div><div><span style="font-family:'calibri' , 'helvetica' , sans-serif;font-size:12pt"> "W" is better API, that "A".</span></div><div><font face="calibri, helvetica, sans-serif"><span style="font-size:16px">Support more longer lengths of file and directory names etc.</span></font></div><div><font face="calibri, helvetica, sans-serif"><span style="font-size:16px"><br /></span></font></div><div><font face="calibri, helvetica, sans-serif"><span style="font-size:16px"> For test "W" API try Norton Commander like software named FAR Manager v2.XX/v3.XX.</span></font></div><div><font face="calibri, helvetica, sans-serif"><span style="font-size:16px"><br /></span></font></div><div><font face="calibri, helvetica, sans-serif"><span style="font-size:16px"> For old style ( but Windows 95 compatible) "A" API use FAR Manager 1.XX.</span></font></div><div><font face="calibri, helvetica, sans-serif"><span style="font-size:16px"><br /></span></font></div><div><font face="calibri, helvetica, sans-serif"><span style="font-size:16px"> Oh: You can read source code of FAR.</span></font></div><div><font face="calibri, helvetica, sans-serif"><span style="font-size:16px">May be, it's best "knoledge base" of programming task related file management and editing.</span></font></div><div><br /></div><div><br /></div><div>> <span style="font-family:'calibri' , 'helvetica' , sans-serif;font-size:12pt">maybe UTF8 ?</span></div><div><br /></div><div> Native utf-8 has only Windows 10 1809 ( and later)</div><div>with software compiled by MS VS 2019 with modern SDK.</div><div><br /></div><div> It's better that nothing, but isn't best variant.</div><div><br /></div><div><br /></div><div>Best regards, Victor Miasnikov</div><div><br /></div><div><br /></div><div>18.03.2021, 08:43, "Jay K" <jayk123@hotmail.com>:</div><blockquote><div dir="ltr">
<div style="color:rgb( 0 , 0 , 0 );font-family:'calibri' , 'helvetica' , sans-serif;font-size:12pt">
We have this common pattern:
<div><br />
</div>
<div> fname := M3toC.SharedTtoS(p);</div>
<div> handle := WinBase.CreateFile(fname, ...);</div>
<div> .</div>
<div> .</div>
<div> .</div>
<div> M3toC.FreeSharedS(p, fname);</div>
<div><br />
</div>
<div>Presumably we are supposed to now "rewrite" them all, like:</div>
<div><br />
</div>
<div> fname := M3toC.SharedTtoW(p);</div>
<div> handle := WinBase.CreateFileW(fname, ...);</div>
<div> .<br />
</div>
<div> .</div>
<div> .</div>
<div> M3toC.FreeSharedW(p, fname);</div>
<div><br />
</div>
<div>?</div>
<div>or, um, maybe not quite.</div>
<div><br />
</div>
<div>For the shared-not-writable case, and the string has all bytes < 0x80,</div>
<div>this causes, um, an unnecessary heap allocation and copy.</div>
<div><br />
</div>
<div>So you kinda want something like:</div>
<div><br />
</div>
<div> fname := M3toC.SharedTtoX(p); (* X is for unknown or varying *)</div>
<div> IF fname.wide # NIL THEN</div>
<div> handle := WinBase.CreateFileW(fname.wide, ..); (* or "unicode"? or just "W"? *)</div>
<div> ELSE</div>
<div> handle := WinBase.CreateFile(fname.narrow, ..); (* or "ascii"? or just "A"? *)</div>
<div> END;</div>
<div><br />
</div>
<div>but:</div>
<div> 1. of course this is cumbersome</div>
<div> 2. the next layer down is going to pay the same cost anyway, so might as well</div>
<div> go with my first suggestion? That is, CreateFileA calls CreateFileW anyway.</div>
<div> Someone has to pay the cost and it is basically the same either way.</div>
<div> Though on some systems the heap is avoided via a thread local.</div>
<div><br />
</div>
<div>Our free function might defer to GC, might not. CreateFileA of course does not.</div>
<div><br />
</div>
<div> And you know, I'm assuming not Windows 95 here.</div>
<div> </div>
<div>Perhaps WinBase.CreateFile could be some kind of wrapper that does this work.</div>
<div>Perhaps SharedTtoS could silently change to this new dynamic thing.</div>
<div><br />
</div>
<div>Or just continue to ignore it for a while long?</div>
<div>Or maybe UTF8?</div>
<div><br />
</div>
- Jay<br />
</div>
</div>
,<p>_______________________________________________<br />M3devel mailing list<br /><a href="mailto:M3devel@elegosoft.com" target="_blank">M3devel@elegosoft.com</a><br /><a href="https://m3lists.elegosoft.com/mailman/listinfo/m3devel" target="_blank">https://m3lists.elegosoft.com/mailman/listinfo/m3devel</a><br /></p></blockquote>