运行时.Net Windows表单阿拉伯语编码问题

时间:2016-08-29 06:00:08

标签: vb.net visual-studio windows-forms-designer

我在VS2008和Windows Vista下创建了一个VB.net Windows窗体项目,现在当我将代码转到其他具有VS2015和Windows 10的PC时我遇到了编码问题,应用程序中有阿拉伯字幕,Visual Studio能够阅读这些标题,但当我点击开始(F5)编译并运行应用程序时,我看到所有阿拉伯语文本都没有编码。我知道当我从旧电脑上购买应用程序的编译版本并在新电脑中运行时,它的行为符合预期,并且所有阿拉伯文本都显示良好,因此这里的问题是在Windows 10下VS2015的编译时间。

我搜索了这个问题,但所有的建议是尝试用代码编辑器打开文件并使用兼容的编码,但实际上我没有读取代码内容的问题,问题是在编译代码时它不会编码阿拉伯文字。

以下是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

这是预期的屏幕:

enter image description here

这是我在编译后获得的屏幕:

enter image description here

请告知。

1 个答案:

答案 0 :(得分:0)

我设法解决了这个问题,但是我花了很多时间来完成它。

解决方案如下:

  1. 使用Visual Basic Editor With Encoding打开包含arabic的每个文件,然后选择Arabic Windows Codepage 1256。
  2. 点击另存为,然后在保存屏幕中选择保存按钮上的箭头,选择使用编码保存并选择utc-8。
  3. 它将使用具有良好格式的新文件替换旧文件,在我完成所有文件后,我构建解决方案并运行它,一切都按预期工作。 (超过70个文件,每个文件一个用于设计,另一个用于代码,所以基本上是140个文件)

    我希望我对这个问题的经验可以帮助那些遇到同样问题的人。