区域与语言CultureInfo

news2024/9/21 22:52:34

CultureInfo 类

命名空间:

System.Globalization

程序集:

System.Globalization.dll

提供有关特定区域性(对于非托管代码开发,则称为“区域设置”)的信息。 这些信息包括区域性的名称、书写系统、使用的日历、字符串的排序顺序以及对日期和数字的格式化设置。

LCID

LCID,全称 Locale Identifier,区域设置标识符,用于确定特定地区和语言的区域设置
使用LCID是为了标识不同地区和语言的代码。它是Locale Identifier(区域设置标识符)的缩写,用于表示不同地区和语言的组合。
每个LCID都是一个32位的无符号整数,由语言ID和子语言ID组成。语言ID是指一种语言,而子语言ID指的是地区或区域设置。
在Windows操作系统中,LCID被广泛用于识别和设置地区设置,如日期和时间格式、货币单位、数字格式、键盘布局等。

本文演示打印显示所有区域信息到表格中.

新建Windows应用程序CultureDemo

FormCulture窗体设计如图:

窗体设计器代码如下:

FormCulture.Designer.cs文件


namespace CultureDemo
{
    partial class FormCulture
    {
        /// <summary>
        /// 必需的设计器变量。
        /// </summary>
        private System.ComponentModel.IContainer components = null;

        /// <summary>
        /// 清理所有正在使用的资源。
        /// </summary>
        /// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }

        #region Windows 窗体设计器生成的代码

        /// <summary>
        /// 设计器支持所需的方法 - 不要修改
        /// 使用代码编辑器修改此方法的内容。
        /// </summary>
        private void InitializeComponent()
        {
            this.dgvCultureList = new System.Windows.Forms.DataGridView();
            this.rtxtMessage = new System.Windows.Forms.RichTextBox();
            this.Column8 = new System.Windows.Forms.DataGridViewTextBoxColumn();
            this.Column1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
            this.Column2 = new System.Windows.Forms.DataGridViewTextBoxColumn();
            this.Column3 = new System.Windows.Forms.DataGridViewTextBoxColumn();
            this.Column4 = new System.Windows.Forms.DataGridViewTextBoxColumn();
            this.Column5 = new System.Windows.Forms.DataGridViewTextBoxColumn();
            this.Column6 = new System.Windows.Forms.DataGridViewTextBoxColumn();
            this.Column7 = new System.Windows.Forms.DataGridViewTextBoxColumn();
            ((System.ComponentModel.ISupportInitialize)(this.dgvCultureList)).BeginInit();
            this.SuspendLayout();
            // 
            // dgvCultureList
            // 
            this.dgvCultureList.AllowUserToAddRows = false;
            this.dgvCultureList.AllowUserToDeleteRows = false;
            this.dgvCultureList.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
            this.dgvCultureList.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
            this.Column8,
            this.Column1,
            this.Column2,
            this.Column3,
            this.Column4,
            this.Column5,
            this.Column6,
            this.Column7});
            this.dgvCultureList.Location = new System.Drawing.Point(12, 12);
            this.dgvCultureList.Name = "dgvCultureList";
            this.dgvCultureList.ReadOnly = true;
            this.dgvCultureList.RowHeadersWidth = 25;
            this.dgvCultureList.RowTemplate.Height = 23;
            this.dgvCultureList.Size = new System.Drawing.Size(1083, 331);
            this.dgvCultureList.TabIndex = 0;
            this.dgvCultureList.CellContentClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dgvCultureList_CellContentClick);
            this.dgvCultureList.CellEnter += new System.Windows.Forms.DataGridViewCellEventHandler(this.dgvCultureList_CellEnter);
            // 
            // rtxtMessage
            // 
            this.rtxtMessage.Location = new System.Drawing.Point(12, 364);
            this.rtxtMessage.Name = "rtxtMessage";
            this.rtxtMessage.ReadOnly = true;
            this.rtxtMessage.Size = new System.Drawing.Size(1083, 299);
            this.rtxtMessage.TabIndex = 1;
            this.rtxtMessage.Text = "";
            // 
            // Column8
            // 
            this.Column8.HeaderText = "序号";
            this.Column8.Name = "Column8";
            this.Column8.ReadOnly = true;
            this.Column8.Width = 60;
            // 
            // Column1
            // 
            this.Column1.HeaderText = "LCID";
            this.Column1.Name = "Column1";
            this.Column1.ReadOnly = true;
            this.Column1.Width = 70;
            // 
            // Column2
            // 
            this.Column2.HeaderText = "Name";
            this.Column2.Name = "Column2";
            this.Column2.ReadOnly = true;
            // 
            // Column3
            // 
            this.Column3.HeaderText = "DisplayName";
            this.Column3.Name = "Column3";
            this.Column3.ReadOnly = true;
            this.Column3.Width = 120;
            // 
            // Column4
            // 
            this.Column4.HeaderText = "EnglishName";
            this.Column4.Name = "Column4";
            this.Column4.ReadOnly = true;
            this.Column4.Width = 120;
            // 
            // Column5
            // 
            this.Column5.HeaderText = "NativeName";
            this.Column5.Name = "Column5";
            this.Column5.ReadOnly = true;
            this.Column5.Width = 140;
            // 
            // Column6
            // 
            this.Column6.HeaderText = "Calendar";
            this.Column6.Name = "Column6";
            this.Column6.ReadOnly = true;
            this.Column6.Width = 250;
            // 
            // Column7
            // 
            this.Column7.HeaderText = "TextInfo";
            this.Column7.Name = "Column7";
            this.Column7.ReadOnly = true;
            this.Column7.Width = 220;
            // 
            // FormCulture
            // 
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.ClientSize = new System.Drawing.Size(1107, 692);
            this.Controls.Add(this.rtxtMessage);
            this.Controls.Add(this.dgvCultureList);
            this.Name = "FormCulture";
            this.Text = "区域与文化Culture";
            this.Load += new System.EventHandler(this.FormCulture_Load);
            ((System.ComponentModel.ISupportInitialize)(this.dgvCultureList)).EndInit();
            this.ResumeLayout(false);

        }

        #endregion

        private System.Windows.Forms.DataGridView dgvCultureList;
        private System.Windows.Forms.RichTextBox rtxtMessage;
        private System.Windows.Forms.DataGridViewTextBoxColumn Column8;
        private System.Windows.Forms.DataGridViewTextBoxColumn Column1;
        private System.Windows.Forms.DataGridViewTextBoxColumn Column2;
        private System.Windows.Forms.DataGridViewTextBoxColumn Column3;
        private System.Windows.Forms.DataGridViewTextBoxColumn Column4;
        private System.Windows.Forms.DataGridViewTextBoxColumn Column5;
        private System.Windows.Forms.DataGridViewTextBoxColumn Column6;
        private System.Windows.Forms.DataGridViewTextBoxColumn Column7;
    }
}

相关程序FormCulture如下:

FormCulture.cs文件

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace CultureDemo
{
    public partial class FormCulture : Form
    {
        public FormCulture()
        {
            InitializeComponent();
            /* LCID,全称 Locale Identifier,区域设置标识符,用于确定特定地区和语言的区域设置
             * 使用LCID是为了标识不同地区和语言的代码。它是Locale Identifier(区域设置标识符)的缩写,用于表示不同地区和语言的组合。
             * 每个LCID都是一个32位的无符号整数,由语言ID和子语言ID组成。语言ID是指一种语言,而子语言ID指的是地区或区域设置。
             * 在Windows操作系统中,LCID被广泛用于识别和设置地区设置,如日期和时间格式、货币单位、数字格式、键盘布局等。
            */
        }

        private void FormCulture_Load(object sender, EventArgs e)
        {
            dgvCultureList.Rows.Clear();
            CultureInfo[] cultureInfos = CultureInfo.GetCultures(CultureTypes.NeutralCultures);
            for (int i = 0; i < cultureInfos.Length; i++)
            {
                int lcid = cultureInfos[i].LCID;
                string name = cultureInfos[i].Name;
                string displayName = cultureInfos[i].DisplayName;
                string englishName = cultureInfos[i].EnglishName;
                string nativeName = cultureInfos[i].NativeName;
                Calendar calendar = cultureInfos[i].Calendar;
                TextInfo textInfo = cultureInfos[i].TextInfo;
                string strTextInfo = $"LCID:{textInfo.LCID},CultureName:{textInfo.CultureName},ANSICodePage:{textInfo.ANSICodePage}";
                dgvCultureList.Rows.Add(i + 1, lcid, name, displayName, englishName, nativeName, calendar.GetType(), strTextInfo);
            }
        }

        private void dgvCultureList_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            rtxtMessage.Clear();
            if (e.RowIndex < 0 || e.ColumnIndex < 0) 
            {
                return;
            }
            CultureInfo cultureInfo = new CultureInfo(Convert.ToString(dgvCultureList[2, e.RowIndex].Value));
            Calendar calendar = cultureInfo.Calendar;
            string calendarDescription = "";
            if (calendar.GetType() == typeof(GregorianCalendar))
            {
                calendarDescription = "格里高利日历【公历】";
            }
            else 
            {
                calendarDescription = calendar.GetType().Name;
            }
            TextInfo textInfo = cultureInfo.TextInfo;
            string strTextInfo = $"    LCID:{textInfo.LCID},\n    CultureName:{textInfo.CultureName},\n    ANSICodePage:{textInfo.ANSICodePage}";
            rtxtMessage.AppendText($@"LCID:{cultureInfo.LCID},
Name:{cultureInfo.Name},
DisplayName:{cultureInfo.DisplayName},
EnglishName:{cultureInfo.EnglishName},
NativeName:{cultureInfo.NativeName},
Calendar:{calendar.GetType()},
     日历描述:{calendarDescription}  
TextInfo:
{strTextInfo}");
        }

        private void dgvCultureList_CellEnter(object sender, DataGridViewCellEventArgs e)
        {
            dgvCultureList_CellContentClick(null, e);
        }
    }
}

运行如图:

阿拉伯语

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/1995207.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

56 锐键交换机开局

锐键交换机开局 一 锐键视图切换 1 Ruijie> 用户视图 2 Ruijie# 特权模式 3 Ruijie(config)# 全局配置模式 4 Ruijie(config-if-GigabitEthernet 1/1/1)# 接口配置模式 5 Ruijie(config)#show vlan 6 exit (退出) 7 enable(进入)

【电子数据取证】支持最新版微信、企业微信、钉钉等重点应用数据提取分析!

文章关键词&#xff1a;电子数据取证、手机取证、云取证、电子物证、仿真取证 针对取证调查员目前在案件现场无法提取通讯聊天数据的情况&#xff0c;为了更好地适应这一实战需求&#xff0c;龙信科技快速响应对A303“鹰眼”介质快取系统和A315计算机快速采集系统全面升级&…

java10-集合框架

1. 集合的简介 1.1什么是集合 集合Collection&#xff0c;也是一个数据容器&#xff0c;类似于数组&#xff0c;但是和数组是不一样的。集合是一个可变的容器&#xff0c;可以随时向集合中添加元素&#xff0c;也可以随时从集合中删除元素。另外&#xff0c;集合还提供了若干个…

人工智能安全态势和趋势

吴世忠 中工院士 国家保密科技委主任 重大风险隐患呼唤加强安全研究&#xff0c;人工智能面临未来担忧 1 总体态势 1.1 相对于技术发展&#xff0c;安全研究严重滞后 1.2 我国研究十分活跃&#xff0c;论文数量遥遥领先 1.3 影响力美国排名第一&#xff0c;大厂大学作用大 1…

【python】Python操作Redis数据库的详细教程与应用实战

✨✨ 欢迎大家来到景天科技苑✨✨ &#x1f388;&#x1f388; 养成好习惯&#xff0c;先赞后看哦~&#x1f388;&#x1f388; &#x1f3c6; 作者简介&#xff1a;景天科技苑 &#x1f3c6;《头衔》&#xff1a;大厂架构师&#xff0c;华为云开发者社区专家博主&#xff0c;…

三防平板助力MES系统,实现工厂移动式生产报工

在当今竞争激烈的制造业环境中&#xff0c;提高生产效率、优化生产流程以及实现精准的生产管理已经成为企业生存和发展的关键。 MES系统作为连接企业计划层和控制层的桥梁&#xff0c;在实现生产过程的信息化、数字化和智能化方面发挥着重要作用。与此同时&#xff0c;三防平板…

JNPF快速开发平台助力企业实现工作流自动化

随着企业信息化建设的不断深入&#xff0c;工作流自动化已成为提升企业效率、优化业务流程的关键手段。JNPF快速开发平台凭借其强大的功能和灵活的配置&#xff0c;为众多企业提供了实现工作流自动化的高效解决方案。 关于低代码开发平台的普及应用 随着信息技术的迅猛发展&…

高中数学必修一函数部分重难点(上)

高中数学必修一函数部分重难点&#xff08;上&#xff09; 本文主要引出映射的概念&#xff0c;明确函数即为映射的一种方式&#xff0c;同时本篇叙述了我在初学时的困难点—定义域等以及当时所觉的难题&#xff0c;最后一图为纯手整理的干货&#xff0c;需要可以留下三联自行取…

Swagger 自动生成 Dubbo 服务的接口文档,以及测试调用

1. 概述 在使用 SpringMVC 构建 HTTP API 时&#xff0c;我们可以通过 Swagger 自动生成 HTTP 接口文档&#xff0c;通过 Swagger UI 界面上进行 HTTP 接口调试。如下图所示&#xff1a; Swagger HTTP 界面 秃头提示&#xff1a;对 Swagger 不太了解的胖友&#xff0c;可以去阅…

论文阅读笔记:Semi-Supervised Semantic Segmentation Using Unreliable Pseudo-Labels

论文阅读笔记&#xff1a;Semi-Supervised Semantic Segmentation Using Unreliable Pseudo-Labels 1 背景2 创新点3 方法4 模块4.1 伪标签4.2 使用不可靠的伪标签 5 效果5.1 与SOTA方法对比5.2 消融实验5.3 定性结果 6 结论 论文&#xff1a;https://arxiv.org/pdf/2203.03884…

北京崇文门中医院贾英才主任:战胜头晕,重获“清醒人生”

头晕&#xff0c;这个看似常见却又恼人的症状&#xff0c;常常让患者的生活陷入困境。在北京崇文门中医院&#xff0c;有个叫贾英才的医生&#xff0c;他凭借医术&#xff0c;给不少头晕患者带去了希望。 北京崇文门中医院贾英才主任在医学领域辛勤耕耘多年&#xff0c;对于头晕…

ubuntu20从docker安装到制作自己的镜像使用记录

ubuntu20从docker安装到制作自己的镜像使用记录 第一章&#xff1a;配置环境 1.ubuntu20 2.docker镜像18.04 3.参考&#xff1a;https://www.runoob.com/docker/docker-tutorial.html 第二章&#xff1a;安装docker 一、安装docker 参考1&#xff1a;Ubuntu安装docker并运…

Spring Cloud微服务项目文件上传/下载

在现代的微服务架构中&#xff0c;文件上传与下载是常见的需求&#xff0c;尤其是在需要处理大量文件数据的系统中。Spring Cloud 提供了灵活的工具和组件&#xff0c;使得在微服务中实现文件上传和下载变得高效而简便。 本文博主将详细介绍如何在 Spring Cloud 微服务项目中实…

【Kubernetes】k8s集群之Pod容器资源限制和三种探针

目录 一、Pod容器的资源限制 1.资源限制 2.Pod 和容器的资源请求与限制 3.CPU 资源单位 4.内存资源单位 二、Pod容器的三种探针 1.探针的三种规则 2.Probe支持三种检查方法&#xff1a; 一、Pod容器的资源限制 1.资源限制 当定义 Pod 时可以选择性地为每个容器设定所…

成都数字产业中心崛起,树莓集团如何加速国际数字影像产业园的全球步伐?

在数字化浪潮的推动下&#xff0c;成都数字产业中心近年来强势崛起&#xff0c;展现出令人瞩目的发展态势。据统计&#xff0c;过去五年间&#xff0c;成都数字产业的年均增长率超过了 20%&#xff0c;这一数据充分证明了其强大的发展动力。而在这片充满活力与创新的土地上&…

数据结构 JAVADS ——部分栈题目分享 (持续更新版)

前言 大概十天前,笔者更新了如何手搓一个简易的栈 入门数据结构JAVA DS ——手搓 栈-CSDN博客 在本篇博客中,笔者就分享几个题目,这同样是一个持续 更新的博客,但是我不保证更新频率就是了 哈哈! 那么我们就来看题目吧 第一题 1.小蓝的括号串1 - 蓝桥云课 (lanqiao.cn) …

如何在 Windows 上设置 MacOS 云主机

在Windows上设置MacOS云主机实际上涉及在Windows环境中模拟或远程管理MacOS系统&#xff0c;因为直接在Windows上运行MacOS作为云主机的主操作系统是不可能的&#xff0c;因为MacOS是为苹果硬件设计的。不过&#xff0c;有几种方法可以实现类似的功能&#xff1a; 1. 使用虚拟机…

Haskell HTTP请求:如何解读响应状态

在互联网技术领域&#xff0c;HTTP请求是客户端与服务器之间通信的基础。无论是网页浏览、API调用还是网络服务的交互&#xff0c;HTTP协议都扮演着核心角色。在本文中&#xff0c;我们将探讨如何在Haskell编程语言中发起HTTP请求&#xff0c;并重点介绍如何解读HTTP响应状态。…

学懂C++ (二十一):高级教程——深入C++多线程开发详解

C多线程开发详解 多线程编程是现代应用程序开发中不可或缺的一部分。C11引入了对多线程的支持&#xff0c;使得程序员能够更方便地利用多核处理器&#xff0c;提高程序的性能和响应能力。本文将全面而深入地探讨C的多线程相关概念&#xff0c;包括线程的创建与管理、互斥量…

PDF怎么在线转Word?介绍四种转换方案

PDF怎么在线转Word&#xff1f;在数字化办公时代&#xff0c;文档的互换性变得尤为重要。PDF格式因其跨平台兼容性和版面固定性而广受欢迎&#xff0c;但有时我们可能需要将PDF文件转换为Word文档&#xff0c;以便进行编辑或进一步处理。以下是四种常见的在线PDF转Word的方法&a…