当前位置:网站首页>ABAP 里文件操作涉及到中文字符集的问题和解决方案试读版
ABAP 里文件操作涉及到中文字符集的问题和解决方案试读版
2022-08-10 12:24:00 【汪子熙】
我们在实际项目特别是一些系统集成项目中,经常遇到需要接收远端发送过来的二进制流,并进行解析的场景。这个二进制流的内容,可能是一些二进制文件,比如 PDF,JPG 等格式的文件,也可能是文本文件。对于文本文件来说,我们需要将二进制流,重新还原成用户可读的文本。这就是本文要着重讨论的话题。
在开始本步骤的学习之前,请大家务必先完成前置章节的学习:
这个前置章节,将文本文件,以二进制的方式上传到 ABAP 服务器上,来模拟一个来自远端的内容提供者(Content Provider) 提供的二进制流,类型为 xstring
. 这些二进制流的实际内容,是一些包含中文字符的文本,本文我们的任务就是,把这些二进制流,重新转换回用户可读的文本,然后打印出来。
我们新建一个文本文件,输入一个汉字 汪
,文件名另存为 汪-utf8.txt
, encoding 选择 UTF-8.
这个文件的大小显示为 3 个字节。这是符合我们期望的行为,因为 UTF-8 是 Unicode 的一种实现方式,而一个汉字的 Unicode 值的范围是 0X4E00 到 0x9FA5,如果采取 UTF-8 编码,需要 3 个字节。
下面我们将会在 ABAP 代码里,针对包含了这个中文字符的文本文件,进行各种操作。
详细介绍请看这篇文章。
总结
在使用 ABAP 进行包含到中文字符的文件操作时,首先一定要明确当前中文字符,是根据哪一个字符集进行编码,然后从 ABAP 数据库表 TCP00 里找到该字符集在 ABAP 系统中的编号,确保包含中文内容的二进制流,同传入的 ABAP Encoding 值相匹配,这样就一定能得到正确的处理结果。
边栏推荐
- 【iOS】Organization of interviews
- 「企业架构」应用架构概述
- Overseas media publicity. What problems should domestic media pay attention to?
- 想问下大佬们 ,cdc oracle初始化一张300万的表任务运行着后面就这个错 怎么解决哇
- 10 款更先进的开源命令行工具
- 交换机的基础知识
- es6-promise对象详解
- 查看 CUDA cudnn 版本 & 测试 cuda 和 cudnn 有效性「建议收藏」
- Custom filters and interceptors implement ThreadLocal thread closure
- kubernetes介绍
猜你喜欢
G1和CMS的三色标记法及漏标问题
AICOCO AI Frontier Promotion (8.10)
Keithley DMM7510 accurate measurement of ultra-low power consumption equipment all kinds of operation mode power consumption
What are the five common data types of Redis?What is the corresponding data storage space?Take you to learn from scratch
Polygon zkEVM工具——PIL和CIRCOM
es6-promise对象详解
实践为主,理论为辅!腾讯大佬MySQL高阶宝典震撼来袭!
Reversing words in a string in LeetCode
DNS欺骗-教程详解
MySQL索引的B+树到底有多高?
随机推荐
燃炸!字节跳动成功上岸,只因刷爆LeetCode算法面试题
Wirshark common operations and tcp three-way handshake process example analysis
Nanodlp v2.2/v3.0 light curing circuit board, connection method of mechanical switch/photoelectric switch/proximity switch and system state level setting
Detailed explanation of es6-promise object
娄底妆品实验室建设规划构思
金山云要飘到哪里?
NodeJs原理 - Stream(二)
Loudi Sewage Treatment Plant Laboratory Construction Management
Code Casual Recording Notes_Dynamic Programming_70 Climbing Stairs
[Collection] HashSet and ArrayList lookup Contains() time complexity
iTextSharp操作PDF
LeetCode·297.二叉树的序列化与反序列化·DFS·BFS
Chapter9 : De Novo Molecular Design with Chemical Language Models
A detailed explanation of implementation api embed
Twikoo腾讯云函数部署转移到私有部署
代码随想录笔记_动态规划_70爬楼梯
关于flask中static_folder 和 static_url_path参数理解
MySQL相关问题整理
AtCoder Beginner Contest 077 D - Small Multiple
虚拟机桥接模式不能上网