您当前的位置:首页 > 养生 > 内容

简体字转换繁体字的方法,简体字转换繁体字的方法有哪些(从简体字转换为繁体字一个类搞定)

关于【简体字转换繁体字的方法】,简体字转换繁体字的方法有哪些,今天乾乾小编给您分享一下,如果对您有所帮助别忘了关注本站哦。

内容导航:1、简体字转换繁体字的方法2、简体字繁体字转换3、简转繁体字转换4、从简体字转换为繁体字一个类搞定

1、简体字转换繁体字的方法

你知道简体字转换繁体字的方法吗?一起来看看吧! 打开搜狗搜索的界面,如下图所示 输入简体字转换繁体字在查找栏目里,点开弹出界面的在线转换器工具,如下图所示 点开后的界面如下图所示,你可以在这里输入简体字 点击下面的转化为繁体字即可快速转化,转化好的文字还可以进行复制

2、简体字繁体字转换

1.打开任何浏览器。2.在浏览器中搜索“联机繁体字转换工具”3.在搜索结果中点击“在线繁体字转换工具”官网即可进入。

4.然后在首页的文字输入框中输入要转换的繁体字。

5.然后点按“繁体转简体”按钮。6.然后你会发现繁体字已经转换成简体字了。

3、简转繁体字转换

简转繁体字转换的方法如下:电脑:联想电脑天逸510S。系统:Windows10。

软件:WPSOffice11.1.0.10072。

1、用wps打开要转换文字的文档。选中文档,右击鼠标,选择打开方式为“wps文字”。2、在wps上方的工具栏中找到并点击“审阅”工具。3、选中要转换的文字,然后点击审阅,在下方出现的新工具中,找到并点击“简转繁”,简体字原文就会自动转换为繁体文字。

如果原文为繁体字,则选择“繁转简”。

4、从简体字转换为繁体字一个类搞定

一:需求分析

(1)由于公司项目在开发之初没有适配繁体语言,大概是没有考虑到有朝一日项目可以卖到台湾、香港、澳门吧。

(2)但是公司的项目确实卖到澳门了,于是客户要求把项目中的所有字体修改为繁体字,这就苦逼了,公司的项目沉淀了这么多年的代码,感觉到这是一项浩大的工程,但是老大只给了一周的时间要求修改完毕。于是考虑了一下看看这么繁琐的机械化的工作能不能由程序来完成,就各种谷歌百度,试了几种方法,没有成功,于是便手动修改,改了一天,几乎接近崩溃,一天下来累成狗,但是并没有修改多少。于是决定还是看看能不能用程序来搞定,最后整理出来下面的代码,使用Java语言编写,整个项目只用了几分钟就把所有简体字转换成了繁体字。整体思路是 读文件------>修改字体------------------>写文件。使用时只需要调用changeFileFromSimpleChineseToTradionalWithRootPath(String path)方法,并传入文件夹名即可。

二:代码示例

package com.java_study;import com.spreada.utils.chinese.ZHConverter;import java.io.*;import java.util.ArrayList;import java.util.regex.Matcher;import java.util.regex.Pattern;/*** Created by dd on 2022/6/8.*/public class ChangeSimpleToTraditional {public static void changeFileFromSimpleChineseToTradionalWithRootPath(String path){ArrayList<String> tempArray = new ArrayList<String>();ArrayList<String> fileList = traverseFolder2(path , tempArray);System.out.println("文件数组" + fileList);if (fileList.size()==0){return;};for (int i = 0; i<fileList.size() ; i++){readOldFileAndWriteNewFileWithFilePath(fileList.get(i));}}public static void readOldFileAndWriteNewFileWithFilePath(String filePath){// 简体转繁体try{BufferedReader bufRead = new BufferedReader(new InputStreamReader(new FileInputStream(new File(filePath))));StringBuffer strBuffer = new StringBuffer();for (String temp = null;(temp = bufRead.readLine())!= null;temp = null ){Pattern pattern = Pattern.compile("[\u4e00-\u9fcc]+");if (pattern.matcher(temp).find()){temp = getChinese(temp);}strBuffer.append(temp);strBuffer.append(System.getProperty("line.separator"));}System.out.println(strBuffer.toString());bufRead.close();PrintWriter printWriter = new PrintWriter(filePath);printWriter.write(strBuffer.toString().toCharArray());printWriter.flush();printWriter.close();}catch (IOException e){e.printStackTrace();}}

/**把读取的文件的每一行字符串进行正则匹配简体中文

* 并且把匹配到的简体中文替换为繁体

* 并返回替换后的字符串

* paramValue:读文件时候,读取到的每一行字符串*/

public static String getChinese(String paramValue) {String regex = "([\u4e00-\u9fa5]+)";String replacedStr = paramValue;Matcher matcher = Pattern.compile(regex).matcher(paramValue);while (matcher.find()) {System.out.println("----------"+matcher.group(0));ZHConverter converter2 = ZHConverter.getInstance(ZHConverter.TRADITIONAL);String traditionalStr = converter2.convert(matcher.group(0));replacedStr = replacedStr.replace(matcher.group(0),traditionalStr);System.out.println("zyf" + traditionalStr + replacedStr);}return replacedStr;}

/**迭代遍历传入的根文件夹,获取每一级文件夹的每个文件

* 并把文件名称以字符串形式装在数组返回

* path:根文件夹路径

* listFileName:用于返回文件路径的数组,由于这个是迭代方法采用外部传入该数组 */

public static ArrayList<String> traverseFolder2(String path , ArrayList<String> listFileName ) {File file = new File(path);if (file.exists()) {File[] files = file.listFiles();if (files.length == 0) {System.out.println("文件夹是空的!");return null;} else {for (File file2 : files) {if (file2.isDirectory()) {System.out.println("文件夹:" + file2.getAbsolutePath());traverseFolder2(file2.getAbsolutePath(),listFileName);} else {String sbsolutePath = file2.getAbsolutePath();if (sbsolutePath.endsWith(".jsp") || sbsolutePath.endsWith(".js") || sbsolutePath.endsWith(".html") || sbsolutePath.endsWith(".java") ){listFileName.add(file2.getAbsolutePath());}System.out.println("文件:" + file2.getAbsolutePath());}}}} else {System.out.println("文件不存在!");}return listFileName;}}

代码中使用了别人封装好的jar包 ZHConverter,里边封装好了简体字转换成繁体字以及繁体字转换成简体字的方法。

本文关键词:简体字转换繁体字的方法图片,简体字转为繁体字在线转换器,简体字转换成繁体字,简体字转成繁体字,简体字转换为繁体字。这就是关于《简体字转换繁体字的方法,简体字转换繁体字的方法有哪些(从简体字转换为繁体字一个类搞定)》的所有内容,希望对您能有所帮助!


声明:本文版权归原作者所有,转载文章仅为传播更多信息之目的,如作者信息标记有误,请第一时间联系我们修改或删除,谢谢。

上一篇: u盘怎样装系统(没有u盘怎么重装系统)

下一篇: 好听的吃鸡女生名字大全(优秀的吃鸡名字女生)



推荐阅读

网站内容来自网络,如有侵权请联系我们,立即删除! | 软文发布 | 粤ICP备2021106084号