home
products
contribute
download
documentation
forum
Home
Forums
New posts
Search forums
What's new
New posts
All posts
Latest activity
Members
Registered members
Current visitors
Donate
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Search titles only
By:
Menu
Log in
Register
Navigation
Install the app
Install
More options
Contact us
Close Menu
Forums
MediaPortal 1
Development
General Development (no feature request here!)
TBS: CI/CAM support and other improvements
Contact us
RSS
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="FreakyJ" data-source="post: 1019562" data-attributes="member: 106003"><p>Okay I made some progress:</p><p>In the old code there we took every byte once after another and cast it as char (unicode). I changed it now that we collect the bytes in a new byte array until we get to the delimiter which is 0. Now I can take the byte array and convert it to a string using a specific encoding.</p><p> </p><p>The question is now how can I determine which is the src encoding of the cam?!</p><p>eg. I now have something like this:</p><p></p><p>Default uses the system encoding, the problem: if the cam uses something different than the system we get garbage.</p><p>Also if I assume that we get UTF-8 and the Cam sends ASCII we get again garbage :/ At least I didn't got a reasonable result as I used UTF-8. I even don't know which encoding my cam is sending...</p><p> </p><p>my current code:</p><p>[CODE]List<string> entries = new List<string>();</p><p> byte[] entryArray = null;</p><p> string entry = string.Empty;</p><p> int entryCount = 0;</p><p> </p><p> for (int i = 1; i < length; i++)</p><p> {</p><p> if (content[i] == 0)</p><p> {</p><p> //TvLibrary.Log.Log.Debug("OK3");</p><p> //IntPtr unmanagedPointer = Marshal.AllocHGlobal(entryArray.Length);</p><p> //Marshal.Copy(entryArray, 0, unmanagedPointer, entryArray.Length);</p><p> //entry += DvbTextConverter.Convert(unmanagedPointer, "");</p><p> entry += System.Text.Encoding.ASCII.GetString(entryArray, 0, entryArray.Length);</p><p> //TvLibrary.Log.Log.Debug("OK4");</p><p> entries.Add(entry);</p><p> entryCount++;</p><p> entry = string.Empty;</p><p> entryArray = null;</p><p> }</p><p> else</p><p> {</p><p> //if ((content[i] >= 32 && content[i] <= 126) || (content[i] >= 192 && content[i] <= 255))</p><p> //{</p><p> if (entryArray != null)</p><p> {</p><p> //TvLibrary.Log.Log.Debug("OK1");</p><p> byte[] newArray = new byte[entryArray.Length + 1];</p><p> //TvLibrary.Log.Log.Debug("OK1.1");</p><p> entryArray.CopyTo(newArray, 0);</p><p> //TvLibrary.Log.Log.Debug("OK1.2");</p><p> newArray[newArray.Length - 1] = content[i];</p><p> //TvLibrary.Log.Log.Debug("OK1.3");</p><p> entryArray = newArray;</p><p> }</p><p> else</p><p> {</p><p> entryArray = new byte[1];</p><p> entryArray[0] = content[i];</p><p> }</p><p> TvLibrary.Log.Log.Debug("OK2");</p><p> //}</p><p> //else</p><p> //{</p><p> // entry += ' ';</p><p> //}</p><p> }</p><p> }</p><p> entries.Add(System.Text.Encoding.Default.GetString(entryArray, 0, entryArray.Length));[/CODE]</p><p> </p><p><em>any inputs?!</em></p></blockquote><p></p>
[QUOTE="FreakyJ, post: 1019562, member: 106003"] Okay I made some progress: In the old code there we took every byte once after another and cast it as char (unicode). I changed it now that we collect the bytes in a new byte array until we get to the delimiter which is 0. Now I can take the byte array and convert it to a string using a specific encoding. The question is now how can I determine which is the src encoding of the cam?! eg. I now have something like this: Default uses the system encoding, the problem: if the cam uses something different than the system we get garbage. Also if I assume that we get UTF-8 and the Cam sends ASCII we get again garbage :/ At least I didn't got a reasonable result as I used UTF-8. I even don't know which encoding my cam is sending... my current code: [CODE]List<string> entries = new List<string>(); byte[] entryArray = null; string entry = string.Empty; int entryCount = 0; for (int i = 1; i < length; i++) { if (content[i] == 0) { //TvLibrary.Log.Log.Debug("OK3"); //IntPtr unmanagedPointer = Marshal.AllocHGlobal(entryArray.Length); //Marshal.Copy(entryArray, 0, unmanagedPointer, entryArray.Length); //entry += DvbTextConverter.Convert(unmanagedPointer, ""); entry += System.Text.Encoding.ASCII.GetString(entryArray, 0, entryArray.Length); //TvLibrary.Log.Log.Debug("OK4"); entries.Add(entry); entryCount++; entry = string.Empty; entryArray = null; } else { //if ((content[i] >= 32 && content[i] <= 126) || (content[i] >= 192 && content[i] <= 255)) //{ if (entryArray != null) { //TvLibrary.Log.Log.Debug("OK1"); byte[] newArray = new byte[entryArray.Length + 1]; //TvLibrary.Log.Log.Debug("OK1.1"); entryArray.CopyTo(newArray, 0); //TvLibrary.Log.Log.Debug("OK1.2"); newArray[newArray.Length - 1] = content[i]; //TvLibrary.Log.Log.Debug("OK1.3"); entryArray = newArray; } else { entryArray = new byte[1]; entryArray[0] = content[i]; } TvLibrary.Log.Log.Debug("OK2"); //} //else //{ // entry += ' '; //} } } entries.Add(System.Text.Encoding.Default.GetString(entryArray, 0, entryArray.Length));[/CODE] [I]any inputs?![/I] [/QUOTE]
Insert quotes…
Verification
Post reply
Forums
MediaPortal 1
Development
General Development (no feature request here!)
TBS: CI/CAM support and other improvements
Contact us
RSS
Top
Bottom