I think the best solution will be to use these functions, which have the desired parameters and polymorphs:
macro midset(cw)
================
sys ps=strptr s
sys pw=strptr w
int ls=cw*len s
int lw=cw*len w
i*=cw
n*=cw
if i<0 then i=ls+i+cw 'index from right
i-=cw 'base 0
if n>lw then n=lw
if n+i>ls
n=ls-i
if n<0 then return
end if
copy ps+i,pw,n
end macro
function amid(char*s,int i, int n,char* w)
==========================================
midset(1)
end function
function amid(string s,int i, int n,string w)
=============================================
midset(1)
end function
function wmid(wchar*s,int i, int n,wchar* w)
============================================
midset(2)
end function
function wmid(wstring s,int i, int n,wstring w)
===============================================
midset(2)
end function
string s="1234567890"
amid (s,2,3)="abcd"
print s
'
wstring s="1234567890"
wstring w="abcd"
wmid (s,2,3)=w
print s
'
char s="1234567890"
amid (s,2,3)="abcd"
print s
'
wchar s="1234567890"
wstring w="abcd"
wmid (s,2,3)=w
print s