'Convert chars / By Kabuneko 99/07/20
'second chars converted into accent
' a = grave accent
' e = acute accent
' o = circumflex accent (Rôma-ji macron substitute)
' n = tilde
' u = umlaut
' . = others
' x = extra
'when stacked vertically, the groups of chars separated by colons
'in const charset$ make up a table of characters as shown below
' accent$ = columns
' alpha$ = lines
' aeonu.x <- second char
'
' a àáâãäåæ
' e èéê#ë##
' i ìíî#ï#ý
' o òóôõöøœ
' u ùúû#ü##
' A ÀÁÂÃÄÅÆ
' E ÈÉÊ#Ë##
' I ÌÍÎ#Ï#Ý
' O ÒÓÔÕÖØŒ
' U ÙÚÛ#Ü##
' c #ç#####
' C #Ç#####
' n ###ñ##—
' N ###Ñ###
' x “”‘•’#ß
'the table can be modified as long as the number of chars is not changed
'including y + umlaut (&hff) causes a macro error on a Japanese system
dim first$, second$, char$
dim accent, alpha
const accent$ = "aeonu.x"
const alpha$ = "aeiouAEIOUcCnNx"
const charset$ = "àáâãäåæ:èéê#ë##:ìíî#ï#ý:òóôõöøœ:ùúû#ü##:ÀÁÂÃÄÅÆ:ÈÉÊ#Ë##:ÌÍÎ#Ï#Ý:ÒÓÔÕÖØŒ:ÙÚÛ#Ü##:#ç#####:#Ç#####:###ñ##—:###Ñ###:“”‘•’#ß"
proc convert 'convert two chars into one
if @hwnd=0 then exit proc
@MoveLeftChar 'move one char to the left
second$ = chr$(@Code) 'read current char as string
accent = instr(1, accent$, second$) 'determining which accent
if accent = 0 then 'not a character modifier
@MoveRightChar
exit proc
end if
@MoveLeftChar
first$ = chr$(@Code) 'read current char as string
alpha = instr(1, alpha$, first$)
if alpha = 0 then 'not a char to be converted
@MoveRightChar
@MoveRightChar
exit proc
end if
char$ = mid$(charset$, 8*(alpha-1)+accent, 1)
if char$ = "#" then 'there is no such special char
@MoveRightChar
@MoveRightChar
exit proc
end if
@Insert char$
@DeleteChar
@DeleteChar
end proc
'Remove accents - ignore others; uses table at file top
proc main 'Remove accents
dim char, r
if @hwnd=0 then exit proc
r = msgbox("Remove accent marks?", 1)
if r = IDCANCEL then exit proc
@Redraw = 0 'suppress display
@UndoBlock = 1 'facilitate Undo
@@FindRegExp = 1 'use regular expression
@@FindRegExp = -2
@MoveFileTop
@MoveBeginningLine
do while 1
@FindStringBottom "[€-þ]"
if @@SearchFound = 0 then exit do
char = instr(charset$, chr$(@Code))
if char > 0 and char <= 8*14 then
if (char mod 8) < 6 then
@Insert mid$(alpha$, (char/8) + 1, 1)
@DeleteChar
end if
end if
loop
@UndoBlock = 0
@Redraw = 1
call msgbox("Accents removed!")
end proc