当前位置:网站首页>记录一次换行符引起的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,可能会有意想不到的错误。
代码修改为:
边栏推荐
- The [MySQL] time field is set to the current time by default
- 安利!如何提优质的ISSUE?学霸是这样写的!
- CPU的异常处理
- Installation of xshell and xftp
- Serial port debugging tool mobaxtermdownload
- find_ Detailed use guide of CIRC
- Simple and fast digital network (network dolls in the network)
- 网络中的网络(套娃)
- Is there anyone who doesn't know the three cores of concurrent programming?
- 50 tips that unity beginners can definitely use
猜你喜欢

简单快速的数网络(网络中的网络套娃)

Your connection is not private

Understanding of "the eigenvectors corresponding to different eigenvalues cannot be orthogonalized"

How to use Pinia (I) introduce Pinia into the project

大赛报名 | AI+科学计算重点赛事之一——中国开源科学软件创意大赛,角逐十万奖金!

复杂数据没头绪?

Network in network (dolls)
![[UVM actual battle== > episode_3] ~ assertion, sequence, property](/img/78/7ce3a9a4e933a58f90478be53e6e61.png)
[UVM actual battle== > episode_3] ~ assertion, sequence, property

温故知新--常温常新

Technical dry goods | top speed, top intelligence and minimalist mindspore Lite: help Huawei watch become more intelligent
随机推荐
Can I open an account for stock trading on my mobile phone? Is it safe to open an account for stock trading on the Internet
股票怎样在手机上开户安全吗 网上开户炒股安全吗
Freescale 单片机概述
Oracle 數據庫基本知識概念
[microservices] Understanding microservices
手机炒股靠谱吗 网上开户炒股安全吗
1+1<2 ?! HESIC论文解读
50 tips that unity beginners can definitely use
新型冠状病毒变异Delta毒株的模拟(MindSPONGE应用)
根据文件名批量生成文件夹
全网最全的混合精度训练原理
test
【leetcode】275. H index II
kubeadm创建kubernetes集群
[vscade] preview MD file
利用burp精准定位攻击者
05 | 规范设计(下):commit 信息风格迥异、难以阅读,如何规范?
From bitmap to bloom filter, C # implementation
[microservices] understanding microservices
新股民如何网上开户 网上开户炒股安全吗