/// <summary>
/// Send me an ASCII character and I'll return you a list of Unicode characters that
/// best fit map to it. Since you're not telling me a specific charset your're
/// interested in, I'm going to send you data for all of them.
/// </summary>
/// <param name="cAscii">The ASCII character to query on.</param>
/// <param name="sCharset">An option charset name to filter by, valid values include:
/// APL-ISO-IR-68
/// CP424
/// IBMGRAPH
/// US-ASCII-QUOTES
/// windows-1250
/// windows-1251
/// windows-1252
/// windows-1253
/// windows-1254
/// windows-1255
/// windows-1256
/// windows-1257
/// windows-1258
/// windows-874
/// CP864
/// CP037
/// CP1026
/// CP500
/// CP875
/// DINGBATS
/// KEYBOARD
/// SYMBOL
/// symbol
/// zdingbat
/// JAPANESE
/// GSM0338
/// </param>
/// <returns></returns>
public List <String> GetBestfitMappings(char cAscii, string sCharset = "")
{
BestFitMapping bm = new BestFitMapping();
// If an invald charset was entered then set it to the wildcard
if (!bm.charsets.Contains(sCharset))
{
sCharset = "";
}
UniChar uc = new UniChar();
uc.CodePoint = uc.GetCodePoint(cAscii);
IEnumerable <string> query;
// If a charset wasn't specified, filter by the ASCII character
if (String.IsNullOrEmpty(sCharset))
{
query = (from mapping in XDocBestfit.Descendants("Mapping")
where
(string)mapping.Element("Ascii") == uc.CodePoint
select mapping.Element("Unicode").Value);
}
// else filter by the charset too
else
{
query = (from mapping in XDocBestfit.Descendants("Mapping")
where
(string)mapping.Element("Ascii") == "0043" &&
(string)mapping.Element("Charset") == sCharset
select mapping.Element("Unicode").Value);
}
List <String> data = new List <string>();
foreach (var item in query.Distinct())
{
data.Add(item);
}
return(data);
}