Philips ChannelMap\_105 and 110: fixed broken favorites.xml file and DVB\*.xml when channels were renamed

This commit is contained in:
Horst Beham
2021-02-17 16:02:19 +01:00
parent b898b856b7
commit fb37239685
2 changed files with 9 additions and 5 deletions

View File

@@ -556,7 +556,7 @@ namespace ChanSort.Loader.Philips
if (ch.IsNameModified)
{
ch.SetupNode.Attributes["ChannelName"].InnerText = EncodeName(ch.Name, (ch.SetupNode.Attributes["ChannelName"].InnerText.Length + 1) / 5);
ch.SetupNode.Attributes["ChannelName"].InnerText = EncodeName(ch.Name, (ch.SetupNode.Attributes["ChannelName"].InnerText.Length + 1) / 5, true);
attr = ch.SetupNode.Attributes["UserModifiedName"];
if (attr != null)
attr.InnerText = "1";
@@ -587,7 +587,7 @@ namespace ChanSort.Loader.Philips
favListNode.InnerXml = ""; // clear all <FavoriteChannel> child elements but keep the attributes of the current node
var attr = favListNode.Attributes?["Name"];
if (attr != null)
attr.InnerText = EncodeName(this.DataRoot.GetFavListCaption(index - 1), (attr.InnerText.Length + 1)/5);
attr.InnerText = EncodeName(this.DataRoot.GetFavListCaption(index - 1), (attr.InnerText.Length + 1)/5, false);
attr = favListNode.Attributes?["Version"];
if (attr != null && int.TryParse(attr.Value, out var version))
@@ -612,17 +612,18 @@ namespace ChanSort.Loader.Philips
#endregion
#region EncodeName
private string EncodeName(string name, int numBytes)
private string EncodeName(string name, int numBytes, bool upperCaseHexDigits)
{
var bytes = Encoding.Unicode.GetBytes(name);
var sb = new StringBuilder();
var pattern = upperCaseHexDigits ? "0x{0:X2} " : "0x{0:x2} ";
for (int i = 0; i < numBytes - 2; i++)
{
var b = i < bytes.Length ? bytes[i] : 0;
sb.Append($"0x{b:X2} ");
sb.AppendFormat(pattern, b);
}
sb.AppendLine("0x00 0x00"); // always add an end-of-string
sb.Append("0x00 0x00"); // always add an end-of-string
return sb.ToString();
}
#endregion

View File

@@ -1,6 +1,9 @@
ChanSort Change Log
===================
2021-02-17_2
- Philips ChannelMap\_105 and 110: fixed broken favorites.xml file and DVB\*.xml when channels were renamed
2021-02-17
- Panasonic: fixed error reading lists with channels that refer to non-existing transponders
- Philips ChannelMap\_45: incrementing fav list version number when saving and setting the last\_watched\_channel\_id to