From fa63b39e40addf56d1bb0bbd6e0092a15fea54aa Mon Sep 17 00:00:00 2001 From: VladMordock Date: Thu, 18 Feb 2021 03:32:20 +0100 Subject: [PATCH] Fix:UTF8 encoding now works! --- .../Perun_v1/01_Classes/TCPController.cs | 4 +- .../Perun_v1/02_Forms/form_Main.Designer.cs | 85 ++++++++++--------- 02_Windows_App/Perun_v1/02_Forms/form_Main.cs | 1 - 3 files changed, 45 insertions(+), 45 deletions(-) diff --git a/02_Windows_App/Perun_v1/01_Classes/TCPController.cs b/02_Windows_App/Perun_v1/01_Classes/TCPController.cs index 790f7ce..6ae73cb 100644 --- a/02_Windows_App/Perun_v1/01_Classes/TCPController.cs +++ b/02_Windows_App/Perun_v1/01_Classes/TCPController.cs @@ -71,11 +71,11 @@ public class TCPController Console.WriteLine("TCP: Connected"); bTCPConnectionOnline = true; tcpClient = tcpServer.AcceptTcpClient(); //if a connection exists, the server will accept it + nsReadStream = tcpClient.GetStream(); //networkstream is used to send/receive messages nsReadStream.ReadTimeout = 10000; tcpClient.ReceiveTimeout = 10000; - while (tcpClient.Connected && !bCloseConnection && bTCPConnectionOnline) //while the client is connected, we look for incoming messages { StringBuilder CompleteMessage = new StringBuilder(); @@ -93,7 +93,7 @@ public class TCPController { Console.WriteLine("TCP: Read"); numberOfBytesRead = nsReadStream.Read(ReadBuffer, 0, ReadBuffer.Length); - CompleteMessage.AppendFormat("{0}", Encoding.ASCII.GetString(ReadBuffer, 0, numberOfBytesRead)); + CompleteMessage.AppendFormat("{0}", Encoding.UTF8.GetString(ReadBuffer, 0, numberOfBytesRead)); if (numberOfBytesRead == 0) { break; diff --git a/02_Windows_App/Perun_v1/02_Forms/form_Main.Designer.cs b/02_Windows_App/Perun_v1/02_Forms/form_Main.Designer.cs index 3a9dfbf..c48c2d1 100644 --- a/02_Windows_App/Perun_v1/02_Forms/form_Main.Designer.cs +++ b/02_Windows_App/Perun_v1/02_Forms/form_Main.Designer.cs @@ -97,15 +97,15 @@ this.label18 = new System.Windows.Forms.Label(); this.label17 = new System.Windows.Forms.Label(); this.con_GroupBox_7 = new System.Windows.Forms.GroupBox(); + this.label33 = new System.Windows.Forms.Label(); + this.label32 = new System.Windows.Forms.Label(); + this.label31 = new System.Windows.Forms.Label(); + this.label30 = new System.Windows.Forms.Label(); this.label29 = new System.Windows.Forms.Label(); this.label28 = new System.Windows.Forms.Label(); this.label27 = new System.Windows.Forms.Label(); this.label20 = new System.Windows.Forms.Label(); this.tim_HW_status = new System.Windows.Forms.Timer(this.components); - this.label30 = new System.Windows.Forms.Label(); - this.label31 = new System.Windows.Forms.Label(); - this.label32 = new System.Windows.Forms.Label(); - this.label33 = new System.Windows.Forms.Label(); this.con_GroupBox_1.SuspendLayout(); this.con_GroupBox_2.SuspendLayout(); this.con_GroupBox_3.SuspendLayout(); @@ -554,6 +554,7 @@ this.con_Button_Reset_Flags.TabIndex = 26; this.con_Button_Reset_Flags.Text = "Reset error flags"; this.con_Button_Reset_Flags.UseVisualStyleBackColor = true; + this.con_Button_Reset_Flags.Click += new System.EventHandler(this.con_Button_Reset_Flags_Click); // // label12 // @@ -796,6 +797,44 @@ this.con_GroupBox_7.TabStop = false; this.con_GroupBox_7.Text = "System status"; // + // label33 + // + this.label33.AutoSize = true; + this.label33.Location = new System.Drawing.Point(174, 34); + this.label33.Name = "label33"; + this.label33.Size = new System.Drawing.Size(67, 13); + this.label33.TabIndex = 36; + this.label33.Text = "[frame delay]"; + // + // label32 + // + this.label32.AutoSize = true; + this.label32.Location = new System.Drawing.Point(86, 34); + this.label32.Name = "label32"; + this.label32.Size = new System.Drawing.Size(87, 13); + this.label32.TabIndex = 35; + this.label32.Text = "Last frame delay:"; + this.label32.TextAlign = System.Drawing.ContentAlignment.MiddleRight; + // + // label31 + // + this.label31.AutoSize = true; + this.label31.Location = new System.Drawing.Point(174, 16); + this.label31.Name = "label31"; + this.label31.Size = new System.Drawing.Size(61, 13); + this.label31.TabIndex = 34; + this.label31.Text = "[frame time]"; + // + // label30 + // + this.label30.AutoSize = true; + this.label30.Location = new System.Drawing.Point(92, 16); + this.label30.Name = "label30"; + this.label30.Size = new System.Drawing.Size(81, 13); + this.label30.TabIndex = 34; + this.label30.Text = "Last frame time:"; + this.label30.TextAlign = System.Drawing.ContentAlignment.MiddleRight; + // // label29 // this.label29.AutoSize = true; @@ -840,44 +879,6 @@ this.tim_HW_status.Interval = 1000; this.tim_HW_status.Tick += new System.EventHandler(this.tim_HW_status_Tick); // - // label30 - // - this.label30.AutoSize = true; - this.label30.Location = new System.Drawing.Point(92, 16); - this.label30.Name = "label30"; - this.label30.Size = new System.Drawing.Size(81, 13); - this.label30.TabIndex = 34; - this.label30.Text = "Last frame time:"; - this.label30.TextAlign = System.Drawing.ContentAlignment.MiddleRight; - // - // label31 - // - this.label31.AutoSize = true; - this.label31.Location = new System.Drawing.Point(174, 16); - this.label31.Name = "label31"; - this.label31.Size = new System.Drawing.Size(61, 13); - this.label31.TabIndex = 34; - this.label31.Text = "[frame time]"; - // - // label32 - // - this.label32.AutoSize = true; - this.label32.Location = new System.Drawing.Point(86, 34); - this.label32.Name = "label32"; - this.label32.Size = new System.Drawing.Size(87, 13); - this.label32.TabIndex = 35; - this.label32.Text = "Last frame delay:"; - this.label32.TextAlign = System.Drawing.ContentAlignment.MiddleRight; - // - // label33 - // - this.label33.AutoSize = true; - this.label33.Location = new System.Drawing.Point(174, 34); - this.label33.Name = "label33"; - this.label33.Size = new System.Drawing.Size(67, 13); - this.label33.TabIndex = 36; - this.label33.Text = "[frame delay]"; - // // form_Main // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); diff --git a/02_Windows_App/Perun_v1/02_Forms/form_Main.cs b/02_Windows_App/Perun_v1/02_Forms/form_Main.cs index 4b86fb2..9031063 100644 --- a/02_Windows_App/Perun_v1/02_Forms/form_Main.cs +++ b/02_Windows_App/Perun_v1/02_Forms/form_Main.cs @@ -793,6 +793,5 @@ namespace Perun_v1 } } - } }