public static async Task <Encoding> GetDbcsEncoding(string name) { try { return(GetEncoding(name)); } catch { //not supported by system } name = name.ToLower(); var encoding = new DbcsEncoding { _webName = name }; if (Cache.ContainsKey(name)) { var tuple = Cache[name]; encoding._dbcsToUnicode = tuple.Item1; encoding._unicodeToDbcs = tuple.Item2; return(encoding); } var dbcsToUnicode = new char[0x10000]; var unicodeToDbcs = new ushort[0x10000]; try { var file = await Windows.Storage.StorageFile.GetFileFromApplicationUriAsync( new Uri(string.Format("ms-appx:///EncodingMaps/{0}.bin", name))); using (var fs = await file.OpenReadAsync()) using (var reader = new Windows.Storage.Streams.DataReader(fs)) { await reader.LoadAsync((uint)fs.Size); for (int i = 0; i < 0xffff; i++) { ushort u = reader.ReadUInt16(); unicodeToDbcs[i] = u; } for (int i = 0; i < 0xffff; i++) { ushort u = reader.ReadUInt16(); dbcsToUnicode[i] = (char)u; } } Cache[name] = new Tuple <char[], ushort[]>(dbcsToUnicode, unicodeToDbcs); encoding._dbcsToUnicode = dbcsToUnicode; encoding._unicodeToDbcs = unicodeToDbcs; return(encoding); } catch { return(null); } }