I've written a solution in the jsFiddle below:
http://jsfiddle.net/Fresh/F3hG9/
The key part of the solution is to normalize the name used for searching and to also include the original name which will be used for display purposes; you can see this in the definition of "local" below:
var nombres = new Bloodhound({
datumTokenizer: Bloodhound.tokenizers.obj.whitespace('value'),
queryTokenizer: queryTokenizer,
local: $.map(names, function (name) {
// Normalize the name - use this for searching
var normalized = normalize(name);
return {
value: normalized,
// Include the original name - use this for display purposes
displayValue: name
};
})
});
It is the normailze function (shown below) which replaces with "foreign" characters with Western alternatives:
var normalize = function (input) {
$.each(charMap, function (unnormalizedChar, normalizedChar) {
var regex = new RegExp(unnormalizedChar, 'gi');
input = input.replace(regex, normalizedChar);
});
return input;
};
I have omitted charMap (which determines what western character the foreign character maps to) for brevity; you can find the list in the Fiddle.