Thank you Paul that came up with the answer in the comment posted below the initial question.
Using ChrW instead of Chr solves the problem. The working code snipped below.
Function XMLEncode(byVal string)
Dim tmp, i
tmp = string
For i = 160 to 255
tmp = Replace(tmp, chrw(i), "&#" & i & ";")
Next
tmp = Replace(tmp, chrw(34), """) ' "
tmp = Replace(tmp, chrw(39), "'") ' '
tmp = Replace(tmp, chrw(60), "<") ' <
tmp = Replace(tmp, chrw(62), ">") ' >
tmp = Replace(tmp, chrw(38), "&") ' &
XMLEncode = tmp
End Function