* Checking string is ASCII

For users to report plugin bugs and request plugin enhancements; and for authors to test new/new versions of plugins, and to discuss plugin development (in the Programming Technicalities sub-forum). If you want advice on choosing or using a plugin, please ask in General Usage or an appropriate sub-forum.
User avatar
ColeValleyGirl
Megastar
Posts: 4853
Joined: 28 Dec 2005 22:02
Family Historian: V7
Location: Cirencester, Gloucestershire
Contact:

Re: Checking string is ASCII

Post by ColeValleyGirl » 06 Apr 2022 17:29

With reference to chcp, I'd be interest to hear how people interpret this (form chcp.
Programs that you start after you assign a new code page use the new code page. However, programs (except Cmd.exe) that you started before assigning the new code page will continue to use the original code page.
What does this mean for programs that you start after you run chcp?

User avatar
tatewise
Megastar
Posts: 27082
Joined: 25 May 2010 11:00
Family Historian: V7
Location: Torbay, Devon, UK
Contact:

Re: Checking string is ASCII

Post by tatewise » 06 Apr 2022 17:51

Yes, I found that a little ambiguous, which is why I ran the tests I mentioned earlier, where I paused a CMD window that had used CHCP 65001 and ran other command windows, none of which used code page 65001.

I suspect it means programs that you start from within this CMD console after it has assigned a new code page.
Whereas programs started earlier in the same CMD console will retain the code page they were launched with.

In other words, it is stating the blindingly obvious.
In a CMD console, any programs that are invoked will inherit the code page in force at the time and that won't change.
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry

User avatar
Mark1834
Megastar
Posts: 2147
Joined: 27 Oct 2017 19:33
Family Historian: V7
Location: South Cheshire, UK

Re: Checking string is ASCII

Post by Mark1834 » 11 Apr 2022 11:25

This thread has wandered around a little, but to report on my discussion with CP - essentially it seems to come down to the new FH7 ini file functions being what they called "thin wrappers" for the underlying MS structure. I assume "thin wrappers" means just passing parameters to and fro with little if any processing. The MS structure does not support "ANSI" encoding, consistent with their move away from this format.

To quote from CP, "fhSetIniFileValue will create a new INI file in ANSI format if you specify a file that doesn't already exist. If you want to use Unicode, you must first create the file yourself as UTF16-LE (with a BOM) before using fhSetIniFileValue". So there is a mismatch between what the CP function does and what the MS control is expecting.

I didn't pick up any intention to fix that mismatch by creating a UTF-16LE file, but they did admit that the FH help description of the functions is misleading and inadequate, and will be updated to explain the workaround in due course.
Mark Draper

User avatar
ColeValleyGirl
Megastar
Posts: 4853
Joined: 28 Dec 2005 22:02
Family Historian: V7
Location: Cirencester, Gloucestershire
Contact:

Re: Checking string is ASCII

Post by ColeValleyGirl » 11 Apr 2022 11:27

ColeValleyGirl wrote:
05 Apr 2022 12:41
Mark, not tested but I've seen suggestions that if you create the ini file as an empty UTF16 file just containing a BOM, it will then accept UTF16 characters. See http://archives.miloush.net/michkap/arc ... 54992.html.

This is of course assuming that CP are using the relevant Windows API to implement the function.

Edited to add: Tested and it works.

Code: Select all

fhfu = require ('fhFileUtils')
strFilePath = "D:\\OneDrive\\Desktop\\myini.ini"
bOK = fhSaveTextFile(strFilePath,"", "UTF-16LE")
bOK = fhSetIniFileValue(strFilePath,"Main", "цу", "text", "цонцлусионемяуе цу")
var= fhGetIniFileValue(strFilePath,"Main", "цу", "text", "broken")
print (var)
So I was right in my assumption.

User avatar
Mark1834
Megastar
Posts: 2147
Joined: 27 Oct 2017 19:33
Family Historian: V7
Location: South Cheshire, UK

Re: Checking string is ASCII

Post by Mark1834 » 11 Apr 2022 11:31

Indeed, and possibly also your second suggestion that CP may not have been fully aware of the way the MS structure worked. I can't see them not fixing that not insignificant limitation if they were fully aware of it beforehand...
Mark Draper

User avatar
SimonOrde
Program Designer
Posts: 352
Joined: 18 Nov 2002 10:20
Family Historian: V7
Location: Calico Pie

Re: Checking string is ASCII

Post by SimonOrde » 11 Apr 2022 14:26

I don't usually get involved in these discussions, but I wanted to respond to a couple of things Mark said as I thought they might cause confusion. First Mark said: "The MS structure does not support "ANSI" encoding, consistent with their move away from this format". If by the "MS structure" you mean the underlying MS API, this does support ANSI (and UTF16-LE if the INI file is UTF16-LE). The thing it does not support is UTF8. Also Mark said: "there is a mismatch between what the CP function does and what the MS control is expecting". I don't know what this is referring to. There is no mismatch that I am aware of. Finally Mark said "they did admit that the FH help description of the functions is misleading and inadequate." What was actually said was "We will update the Help to make it clearer how to use these functions."

Post Reply