'.Net Windows Form Arabic Encoding issue at Runtime
I created a VB.net windows forms project under VS2008 and Windows Vista, now when I take to code to other PC having VS2015 and Windows 10 I faced an encoding problem, the Application has Arabic captions in it, Visual Studio is able to read those captions but when I click start (F5) to compile and run the app I see that all Arabic text are not encoded. knowing that when I took the compiled version of the app from old pc and run it in the new pc it behave as expected and all Arabic texts are displayed well, so the problem here is on compile time of VS2015 under Windows 10.
I searched around this issue but all advises was to try to open the files with code editor and use the compatible encoding, but actually I don't have problem reading the code content, the problem is when compiling the code it will not encode the Arabic text.
The following is the code of the frmWelcome.Designer.vb
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Class frmWelcome
Inherits System.Windows.Forms.Form
'Form overrides dispose to clean up the component list.
<System.Diagnostics.DebuggerNonUserCode()> _
Protected Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing AndAlso components IsNot Nothing Then
components.Dispose()
End If
MyBase.Dispose(disposing)
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
<System.Diagnostics.DebuggerStepThrough()> _
Private Sub InitializeComponent()
Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(frmWelcome))
Me.btnSalesCenter = New System.Windows.Forms.Button
Me.btnAdministrator = New System.Windows.Forms.Button
Me.btnPurchaseCenter = New System.Windows.Forms.Button
Me.PictureBox1 = New System.Windows.Forms.PictureBox
Me.btnMinimize = New System.Windows.Forms.PictureBox
Me.Label5 = New System.Windows.Forms.Label
Me.btnClose = New System.Windows.Forms.PictureBox
Me.Label3 = New System.Windows.Forms.Label
CType(Me.PictureBox1, System.ComponentModel.ISupportInitialize).BeginInit()
CType(Me.btnMinimize, System.ComponentModel.ISupportInitialize).BeginInit()
CType(Me.btnClose, System.ComponentModel.ISupportInitialize).BeginInit()
Me.SuspendLayout()
'
'btnSalesCenter
'
Me.btnSalesCenter.FlatStyle = System.Windows.Forms.FlatStyle.Flat
Me.btnSalesCenter.Font = New System.Drawing.Font("Times New Roman", 20.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.btnSalesCenter.ForeColor = System.Drawing.Color.Navy
Me.btnSalesCenter.Location = New System.Drawing.Point(408, 276)
Me.btnSalesCenter.Name = "btnSalesCenter"
Me.btnSalesCenter.Size = New System.Drawing.Size(262, 70)
Me.btnSalesCenter.TabIndex = 1
Me.btnSalesCenter.TabStop = False
Me.btnSalesCenter.Text = "قسم المبيعات"
Me.btnSalesCenter.UseVisualStyleBackColor = True
'
'btnAdministrator
'
Me.btnAdministrator.BackColor = System.Drawing.Color.White
Me.btnAdministrator.FlatStyle = System.Windows.Forms.FlatStyle.Flat
Me.btnAdministrator.Font = New System.Drawing.Font("Times New Roman", 20.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.btnAdministrator.ForeColor = System.Drawing.Color.Navy
Me.btnAdministrator.Location = New System.Drawing.Point(408, 200)
Me.btnAdministrator.Name = "btnAdministrator"
Me.btnAdministrator.Size = New System.Drawing.Size(262, 70)
Me.btnAdministrator.TabIndex = 0
Me.btnAdministrator.TabStop = False
Me.btnAdministrator.Text = "الادارة"
Me.btnAdministrator.UseVisualStyleBackColor = False
'
'btnPurchaseCenter
'
Me.btnPurchaseCenter.FlatStyle = System.Windows.Forms.FlatStyle.Flat
Me.btnPurchaseCenter.Font = New System.Drawing.Font("Times New Roman", 20.25!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.btnPurchaseCenter.ForeColor = System.Drawing.Color.Navy
Me.btnPurchaseCenter.Location = New System.Drawing.Point(408, 352)
Me.btnPurchaseCenter.Name = "btnPurchaseCenter"
Me.btnPurchaseCenter.Size = New System.Drawing.Size(262, 70)
Me.btnPurchaseCenter.TabIndex = 21
Me.btnPurchaseCenter.TabStop = False
Me.btnPurchaseCenter.Tag = ""
Me.btnPurchaseCenter.Text = "قسم المشتريات"
Me.btnPurchaseCenter.UseVisualStyleBackColor = True
'
'PictureBox1
'
Me.PictureBox1.Cursor = System.Windows.Forms.Cursors.Hand
Me.PictureBox1.Image = CType(resources.GetObject("PictureBox1.Image"), System.Drawing.Image)
Me.PictureBox1.Location = New System.Drawing.Point(78, 240)
Me.PictureBox1.Name = "PictureBox1"
Me.PictureBox1.Size = New System.Drawing.Size(146, 138)
Me.PictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.CenterImage
Me.PictureBox1.TabIndex = 151
Me.PictureBox1.TabStop = False
'
'btnMinimize
'
Me.btnMinimize.BackColor = System.Drawing.Color.Navy
Me.btnMinimize.Cursor = System.Windows.Forms.Cursors.Hand
Me.btnMinimize.Image = CType(resources.GetObject("btnMinimize.Image"), System.Drawing.Image)
Me.btnMinimize.Location = New System.Drawing.Point(676, 5)
Me.btnMinimize.Name = "btnMinimize"
Me.btnMinimize.Size = New System.Drawing.Size(50, 50)
Me.btnMinimize.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom
Me.btnMinimize.TabIndex = 231
Me.btnMinimize.TabStop = False
'
'Label5
'
Me.Label5.AutoSize = True
Me.Label5.BackColor = System.Drawing.Color.Navy
Me.Label5.Font = New System.Drawing.Font("Times New Roman", 27.75!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Label5.ForeColor = System.Drawing.Color.White
Me.Label5.Location = New System.Drawing.Point(464, 9)
Me.Label5.Name = "Label5"
Me.Label5.Size = New System.Drawing.Size(206, 42)
Me.Label5.TabIndex = 230
Me.Label5.Text = "القائمة الرئيسية"
'
'btnClose
'
Me.btnClose.BackColor = System.Drawing.Color.Navy
Me.btnClose.Cursor = System.Windows.Forms.Cursors.Hand
Me.btnClose.Image = CType(resources.GetObject("btnClose.Image"), System.Drawing.Image)
Me.btnClose.Location = New System.Drawing.Point(732, 5)
Me.btnClose.Name = "btnClose"
Me.btnClose.Size = New System.Drawing.Size(50, 50)
Me.btnClose.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom
Me.btnClose.TabIndex = 229
Me.btnClose.TabStop = False
'
'Label3
'
Me.Label3.BackColor = System.Drawing.Color.Navy
Me.Label3.Font = New System.Drawing.Font("Times New Roman", 27.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Label3.ForeColor = System.Drawing.Color.Navy
Me.Label3.Location = New System.Drawing.Point(0, -3)
Me.Label3.Name = "Label3"
Me.Label3.Size = New System.Drawing.Size(800, 67)
Me.Label3.TabIndex = 228
'
'frmWelcome
'
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.BackColor = System.Drawing.Color.White
Me.ClientSize = New System.Drawing.Size(794, 568)
Me.ControlBox = False
Me.Controls.Add(Me.btnMinimize)
Me.Controls.Add(Me.Label5)
Me.Controls.Add(Me.btnClose)
Me.Controls.Add(Me.Label3)
Me.Controls.Add(Me.PictureBox1)
Me.Controls.Add(Me.btnPurchaseCenter)
Me.Controls.Add(Me.btnSalesCenter)
Me.Controls.Add(Me.btnAdministrator)
Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle
Me.MaximizeBox = False
Me.Name = "frmWelcome"
Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
Me.Text = "القائمة الرئيسية"
CType(Me.PictureBox1, System.ComponentModel.ISupportInitialize).EndInit()
CType(Me.btnMinimize, System.ComponentModel.ISupportInitialize).EndInit()
CType(Me.btnClose, System.ComponentModel.ISupportInitialize).EndInit()
Me.ResumeLayout(False)
Me.PerformLayout()
End Sub
Friend WithEvents btnAdministrator As System.Windows.Forms.Button
Friend WithEvents btnSalesCenter As System.Windows.Forms.Button
Friend WithEvents btnPurchaseCenter As System.Windows.Forms.Button
Friend WithEvents PictureBox1 As System.Windows.Forms.PictureBox
Friend WithEvents btnMinimize As System.Windows.Forms.PictureBox
Friend WithEvents Label5 As System.Windows.Forms.Label
Friend WithEvents btnClose As System.Windows.Forms.PictureBox
Friend WithEvents Label3 As System.Windows.Forms.Label
End Class
This is the expected screen:
And this is the screen I get after compile:
Please Advise.
Solution 1:[1]
I managed to solve the problem, but it took with me a lot of time to finish it.
The solution is as the following:
- Open each file containing arabic with Visual Basic Editor With Encoding and choose Arabic Windows Codepage 1256.
- Click on save as and in the save screen choose the arrow on the save button to select save with encoding and select utc-8.
It will replace the old file with new one with good format, after I finished all files I build the solution and run it and everything worked as expected. (more then 70 files and for each of them one for design and other for code so basically 140 files)
I hope my experience with this problem can help someone who faced the same issue.
Solution 2:[2]
change windows locale in adminstrative language settings to arabic
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Fadl Assaad |
| Solution 2 | Hosam Saleh |


