Apparently I had too much time on my hands.
[code]Public Sub ANSELtoUnicode()
Dim diacriticals As String = “”
Dim ANSELcodePoint As UInt8
Dim UnicodeCodePoint As String
dim input As BinaryStream
dim myFile As FolderItem
'charset2 is the set of ANSEL accented characters 161…207
dim charSet2() as string = array(_
&u0141,&u00D8,&u0110,&u00DE,&u00C6,&u0152,&u01B9,&u00B7,_
&u266D,&u00AE,&u00B1,&u01A0,&u01AF,&u01BC,&uFFFD,&u02BB,_
&u0142,&u00F8,&u0111,&u00FE,&u00E6,&u0153,&u02BA,&u0131,_
&u00A3,&u00F0,&uFFFD,&u01A1,&u01B0,&u25A1,&u25A0,&u00B0,_
&u2113,&u2117,&u00A9,&u266F,&u00BF,&u00A1,&uFFFD,&uFFFD,_
&uFFFD,&uFFFD,&uFFFD,&uFFFD,&u0065,&u006F,&u00DF)
'charset3 is the set of all possible combinations of
'ANSEL combining diacriticals and final character
'The following data was taken from heiner-eichmann.de/gedcom/unicomb.out
'and then machine converted. The format of each element is as follows:
'The first 4 hex digits are the Unicode codepoint output value.
'The remaining hex digit pairs are the ANSEL diacritical prefixes
'and the base character, which make up the dictionary key.
dim charSet3pairs() as string = array(_
“1EA2E041”,“1EBAE045”,“1EC8E049”,“1ECEE04F”,“1EE6E055”,“1EF6E059”,“1EA3E061”,“1EBBE065”,“1EC9E069”,“1ECFE06F”,_
“1EE7E075”,“1EF7E079”,“00C0E141”,“00C8E145”,“00CCE149”,“00D2E14F”,“00D9E155”,“1E80E157”,“1EF2E159”,_
“00E0E161”,“00E8E165”,“00ECE169”,“00F2E16F”,“00F9E175”,“1E81E177”,“1EF3E179”,“00C1E241”,“0106E243”,_
“00C9E245”,“01F4E247”,“00CDE249”,“1E30E24B”,“0139E24C”,“1E3EE24D”,“0143E24E”,“00D3E24F”,“1E54E250”,_
“0154E252”,“015AE253”,“00DAE255”,“1E82E257”,“00DDE259”,“0179E25A”,“00E1E261”,“0107E263”,“00E9E265”,_
“01F5E267”,“00EDE269”,“1E31E26B”,“013AE26C”,“1E3FE26D”,“0144E26E”,“00F3E26F”,“1E55E270”,“0155E272”,_
“015BE273”,“00FAE275”,“1E83E277”,“00FDE279”,“017AE27A”,“01FCE2C6”,“01FDE2E6”,“1E64E2E753”,“1E65E2E773”,_
“00C2E341”,“0108E343”,“00CAE345”,“011CE347”,“0124E348”,“00CEE349”,“0134E34A”,“00D4E34F”,“015CE353”,_
“00DBE355”,“0174E357”,“0176E359”,“1E90E35A”,“00E2E361”,“0109E363”,“00EAE365”,“011DE367”,“0125E368”,_
“00EEE369”,“0135E36A”,“00F4E36F”,“015DE373”,“00FBE375”,“0175E377”,“0177E379”,“1E91E37A”,“1EA8E3E041”,_
“1EC2E3E045”,“1ED4E3E04F”,“1EA9E3E061”,“1EC3E3E065”,“1ED5E3E06F”,“1EA6E3E141”,“1EC0E3E145”,“1ED2E3E14F”,_
“1EA7E3E161”,“1EC1E3E165”,“1ED3E3E16F”,“1EA4E3E241”,“1EBEE3E245”,“1ED0E3E24F”,“1EA5E3E261”,“1EBFE3E265”,_
“1ED1E3E26F”,“1EAAE3E441”,“1EC4E3E445”,“1ED6E3E44F”,“1EABE3E461”,“1EC5E3E465”,“1ED7E3E46F”,“1EACE3F241”,_
“1EC6E3F245”,“1ED8E3F24F”,“1EADE3F261”,“1EC7E3F265”,“1ED9E3F26F”,“00C3E441”,“1EBCE445”,“0128E449”,_
“00D1E44E”,“00D5E44F”,“0168E455”,“1E7CE456”,“1EF8E459”,“00E3E461”,“1EBDE465”,“0129E469”,“00F1E46E”,_
“00F5E46F”,“0169E475”,“1E7DE476”,“1EF9E479”,“1E4CE4E24F”,“1E78E4E255”,“1E4DE4E26F”,“1E79E4E275”,“1E4EE4E84F”,_
“1E4FE4E86F”,“0100E541”,“0112E545”,“1E20E547”,“012AE549”,“014CE54F”,“016AE555”,“0101E561”,“0113E565”,_
“1E21E567”,“012BE569”,“014DE56F”,“016BE575”,“01E2E5C6”,“01E3E5E6”,“1E14E5E145”,“1E50E5E14F”,“1E15E5E165”,_
“1E51E5E16F”,“1E16E5E245”,“1E52E5E24F”,“1E17E5E265”,“1E53E5E26F”,“1E7AE5E855”,“1E7BE5E875”,“0102E641”,_
“0114E645”,“011EE647”,“012CE649”,“014EE64F”,“016CE655”,“0103E661”,“0115E665”,“011FE667”,“012DE669”,_
“014FE66F”,“016DE675”,“1EB2E6E041”,“1EB3E6E061”,“1EB0E6E141”,“1EB1E6E161”,“1EAEE6E241”,“1EAFE6E261”,_
“1EB4E6E441”,“1EB5E6E461”,“1EB6E6F241”,“1EB7E6F261”,“1E02E742”,“010AE743”,“1E0AE744”,“0116E745”,“1E1EE746”,_
“0120E747”,“1E22E748”,“0130E749”,“1E40E74D”,“1E44E74E”,“1E56E750”,“1E58E752”,“1E60E753”,“1E6AE754”,_
“1E86E757”,“1E8AE758”,“1E8EE759”,“017BE75A”,“1E03E762”,“010BE763”,“1E0BE764”,“0117E765”,“1E1FE766”,_
“0121E767”,“1E23E768”,“1E41E76D”,“1E45E76E”,“1E57E770”,“1E59E772”,“1E61E773”,“1E6BE774”,“1E87E777”,_
“1E8BE778”,“1E8FE779”,“017CE77A”,“1E9BE77F”,“01E0E7E541”,“01E1E7E561”,“00C4E841”,“00CBE845”,“1E26E848”,_
“00CFE849”,“00D6E84F”,“00DCE855”,“1E84E857”,“1E8CE858”,“0178E859”,“00E4E861”,“00EBE865”,“1E27E868”,_
“00EFE869”,“00F6E86F”,“1E97E874”,“00FCE875”,“1E85E877”,“1E8DE878”,“00FFE879”,“01DBE8E155”,“01DCE8E175”,_
“1E2EE8E249”,“01D7E8E255”,“1E2FE8E269”,“01D8E8E275”,“01DEE8E541”,“01D5E8E555”,“01DFE8E561”,“01D6E8E575”,_
“01D9E8E955”,“01DAE8E975”,“01CDE941”,“010CE943”,“010EE944”,“011AE945”,“01E6E947”,“01CFE949”,“01E8E94B”,_
“013DE94C”,“0147E94E”,“01D1E94F”,“0158E952”,“0160E953”,“0164E954”,“01D3E955”,“017DE95A”,“01CEE961”,_
“010DE963”,“010FE964”,“011BE965”,“01E7E967”,“01D0E969”,“01F0E96A”,“01E9E96B”,“013EE96C”,“0148E96E”,_
“01D2E96F”,“0159E972”,“0161E973”,“0165E974”,“01D4E975”,“017EE97A”,“01EEE9B7”,“01C4E9F1”,“01C6E9F3”,_
“01EFE992”,“1E66E9E753”,“1E67E9E773”,“00C5EA41”,“016EEA55”,“00E5EA61”,“016FEA75”,“1E98EA77”,“1E99EA79”,_
“01FAEAE241”,“01FBEAE261”,“0150EE4F”,“0170EE55”,“0151EE6F”,“0171EE75”,“00C7F043”,“1E10F044”,“0122F047”,_
“1E28F048”,“0136F04B”,“013BF04C”,“0145F04E”,“0156F052”,“015EF053”,“0162F054”,“00E7F063”,“1E11F064”,_
“0123F067”,“1E29F068”,“0137F06B”,“013CF06C”,“0146F06E”,“0157F072”,“015FF073”,“0163F074”,“1E08F0E243”,_
“1E09F0E263”,“1E1CF0E645”,“1E1DF0E665”,“0104F141”,“0118F145”,“012EF149”,“01EAF14F”,“0172F155”,“0105F161”,_
“0119F165”,“012FF169”,“01EBF16F”,“0173F175”,“01ECF1E54F”,“01EDF1E56F”,“1EA0F241”,“1E04F242”,“1E0CF244”,_
“1EB8F245”,“1E24F248”,“1ECAF249”,“1E32F24B”,“1E36F24C”,“1E42F24D”,“1E46F24E”,“1ECCF24F”,“1E5AF252”,_
“1E62F253”,“1E6CF254”,“1EE4F255”,“1E7EF256”,“1E88F257”,“1EF4F259”,“1E92F25A”,“1EA1F261”,“1E05F262”,_
“1E0DF264”,“1EB9F265”,“1E25F268”,“1ECBF269”,“1E33F26B”,“1E37F26C”,“1E43F26D”,“1E47F26E”,“1ECDF26F”,_
“1E5BF272”,“1E63F273”,“1E6DF274”,“1EE5F275”,“1E7FF276”,“1E89F277”,“1EF5F279”,“1E93F27A”,“1E38F2E54C”,_
“1E5CF2E552”,“1E39F2E56C”,“1E5DF2E572”,“1E68F2E753”,“1E69F2E773”,“1E72F355”,“1E73F375”,“1E00F441”,_
“1E01F461”,“1E2AF948”,“1E2BF968”)
dim charSet3 As new Dictionary
'Build charSet3 transliteration Dictionary
for i as Integer = 0 to UBound(charSet3pairs)
'Get the Unicode codepoint output value
dim cs3value As String = chr(val("&h"+left(charSet3pairs(i),4)))
'Get the ANSEL diacritical prefixes and the base character, which make up the key
dim cs3key As String = mid(charSet3pairs(i),5)
charSet3.Value(cs3key)=cs3value
next
//The program code above this point should probably be placed in a separate
//initialization routine because it doesn’t need to run each time a file is read.
'Get an ANSEL encoded input file and open it
myFile=GetOpenFolderItem("")
'Open file as a read only BinaryStream
input=BinaryStream.Open(myFile,False)
'Now process the input byte by byte
while not input.EOF
ANSELcodePoint = input.ReadUInt8
if ANSELcodePoint<128 Then
'charSet1 - This range of characters is the same in all encodings
if len(diacriticals)>0 then
'There are diacriticals to prefix to this character
diacriticals=diacriticals+right(“00”+hex(ANSELcodePoint),2)
if charSet3.HasKey(diacriticals) then
UnicodeCodePoint=charSet3.Value(diacriticals)
else
'Not found, so go with the unaccented character
UnicodeCodePoint=chr(ANSELcodePoint)
end if
diacriticals=""
else
'No diacriticals, so the character needs no translation
UnicodeCodePoint=chr(ANSELcodePoint)
end if
elseif ANSELcodePoint<161 Then
'This range is Invalid, so convert to Unicode Replacement Character
UnicodeCodePoint=&uFFFD
elseif ANSELcodePoint<208 Then
'This is the ANSEL set of accented characters
UnicodeCodePoint=charSet2(ANSELcodePoint-161)
elseif ANSELcodePoint<224 Then
'This range is Invalid, so convert to Unicode Replacement Character
UnicodeCodePoint=&uFFFD
else
'The ANSEL codepoint is a combining diacritical, so append it to the diacritical string.
diacriticals=diacriticals+right(“00”+hex(ANSELcodePoint),2)
end if
'At this point the input ANSEL character has been converted to Unicode
'So we send it out to be handled by another routine
'For this example we simply display it in a TextArea
myTextArea.AppendText UnicodeCodePoint
wend
End Sub
[/code]