当前位置:网站首页>记录一次换行符引起的bug
记录一次换行符引起的bug
2022-06-27 00:05:00 【华为云】
在学习java以来,一值都把\n当作换行符,偶尔看见有的地方换行符是\r\n,也没有去在意。
但在一次项目中,我需要去向一个接口请求一个证书,然后再把这个证书的字符串,封装首尾,存在一个文件。
证书大概是下面这样。
我请求接口获取的是中间的字符串,而第一行和最后一行是手动添加的。
代码如下:
这个证书是crt格式的,我还需要用openssl把这个crt证书转成p12证书。
结果我执行转换命令的时候,结果如下:
提示找不到证书,后来我把这个证书的内容复制到其他文件,再去执行,居然又能解析了。
想不通为什么,明明两个文件内容一模一样,但是一个证书能解析,一个不行。
后来仔细对比两个证书的内容,发现还是有一点的区别。
一个证书的换行符是占了一个字节,而另一个占了两个字节。
后来查阅资料得知,
回车:Carriage Return 使用转义字符’\r’表示,很显然用的是第2个单词的首字母。
换行:New Line 使用转义字符’\n’表示,很显然用的是第1个单词首字母。
Windows系统里面,每行结尾是“<换行><回车>”,即“\n\r”;如果在一下文件换行使用\n,可能会有意想不到的错误。
代码修改为:
边栏推荐
- com. fasterxml. jackson. databind. exc.MismatchedInputException: Expected array or string. at [Source:x
- 技术干货|什么是大模型?超大模型?Foundation Model?
- Is it reliable to open an account on a stock trading mobile phone? Is it safe to open an account online and speculate in stocks
- Target tracking shooting? Target occlusion shooting? With 1.9 billion installed petal apps, what unique features attract users?
- Network in network (dolls)
- In the Internet industry, there are many certificates with high gold content. How many do you have?
- [microservices] understanding microservices
- 在线上买养老年金险正规安全吗?有没有保单?
- Oracle 數據庫基本知識概念
- No clue about complex data?
猜你喜欢

Memorizing byte order of big and small end
![[微服務]認識微服務](/img/62/e826e692e7fd6e6e8dab2baa4dd170.png)
[微服務]認識微服務

1+1<2 ?! Interpretation of hesic papers

Introduction to software engineering -- Chapter 4 -- formal description technology

When transformer encounters partial differential equation solution
![[UVM actual battle== > episode_3] ~ assertion, sequence, property](/img/78/7ce3a9a4e933a58f90478be53e6e61.png)
[UVM actual battle== > episode_3] ~ assertion, sequence, property

国产框架MindSpore联合山水自然保护中心,寻找、保护「中华水塔」中的宝藏生命

當Transformer遇見偏微分方程求解

Oracle database basics concepts

The most complete hybrid precision training principle in the whole network
随机推荐
如何通俗易懂的描述机器学习的流程?
Memorizing byte order of big and small end
国内外最好的12款项目管理系统优劣势分析
The [MySQL] time field is set to the current time by default
idea 热启动失效解决方案
CPU exception handling
Ten thousand words explanation - mindarmour Xiaobai tutorial!
股票怎样在手机上开户安全吗 网上开户炒股安全吗
Cvpr2022 stereo matching of asymmetric resolution images
手机上可以开户炒股吗 网上开户炒股安全吗
Your connection is not private
How to use Pinia (I) introduce Pinia into the project
冲刺强基计划数学物理专题二
Overview of Freescale MCU
这3个并发编程的核心,竟然还有人不知道?
深度学习方法求解平均场博弈论问题
Intrusion trace cleaning
Oracle 数据库基本知识概念
目前哪个证券公司炒股开户是最好最安全的?
Com. Faster XML. Jackson. DataBind. Exc.mismatchedinputexception: tableau ou chaîne attendu. At [Source: X