当前位置:网站首页>记录一次换行符引起的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,可能会有意想不到的错误。
代码修改为:
边栏推荐
- Why does EDR need defense in depth to combat ransomware?
- 敲重点!最全大模型训练合集!
- 复杂数据没头绪?
- [microservice]eureka
- Understanding of "the eigenvectors corresponding to different eigenvalues cannot be orthogonalized"
- 巧记大小端字节序
- Is the low commission free account opening channel safe?
- In the Internet industry, there are many certificates with high gold content. How many do you have?
- 超硬核!华为智慧屏上的家庭相册竟可以自动精准分类?
- 简单快速的数网络(网络中的网络套娃)
猜你喜欢
随机推荐
Using physical information neural network to solve hydrodynamics equations
2022健康博览会,山东养生保健展会,产后健康、睡眠健康展
论文学习——降雨场次划分方法对降雨控制率的影响分析
idea 热启动失效解决方案
国内外最好的12款项目管理系统优劣势分析
Outside the code: writing is the best way to force growth
Is there anyone who doesn't know the three cores of concurrent programming?
Great health industry annual must attend event, 2022 Shandong International Great Health Industry Expo
Encapsulate servlet unified processing request
Is it safe to buy pension insurance online? Is there a policy?
[microservices] Understanding microservices
How do new investors open accounts online? Is it safe to open accounts online and speculate in stocks
com. fasterxml. jackson. databind. exc.MismatchedInputException: Expected array or string. at [Source:x
【UVM实战 ===> Episode_3 】~ Assertion、Sequence、Property
Leetcode 718. Longest repeating subarray (violence enumeration, to be solved)
Is the low commission free account opening channel safe?
【Mysql】时间字段默认设置为当前时间
我的c语言进阶学习笔记 ----- 关键字
复杂数据没头绪?
Is it safe to open an account on the mobile phone to buy stocks? Is it safe to open an account on the Internet to speculate in stocks






![[microservice]eureka](/img/60/e5fa18d004190d4dadebfb16b93550.png)


