Crate fs to create a file vs file created manually

Hello everyone,

I am testing the fs crate to create a file and create another file with the same content manually. But I notice that the capacity of the file that created manually always bigger than the file created by Rust.

The code to export file from Rust as following:

let file_ini_content = "[IED General]

IEDAddressing=CopyPrefix

[IED Slave]

UnitParameterA=0

UnitParameterB=IEDStatus

UnitParameterC=IEDErrorCount

UnitParameterD=0

UnitParameterE=0

UnitParameterF=0

UnitParameterG=0

UnitParameterH=0

UnitParameterI=0

UnitParameterJ=0

[IED Master]

StatusPointName=IEDStatus

PercentagePointName=IEDPercentage

TotalMsgCountPointName=IEDTotalMsgCount

GoodMsgCountPointName=IEDGoodMsgCount

BadMsgCountPointName=IEDBadMsgCount

TimeoutCountPointName=IEDTimeoutCount

FastScanPointName=IEDFastScan

PortSwitchPointName=IEDPortSwitch

SendMsgCountPointName=IEDSendMsgCount".to_string();

let mut file_ini = File::create("test.iedini").unwrap();

file_ini.write_all(file_ini_content.as_bytes()).unwrap();

Could you help me to explain this?

Hi,

I already found out the problem The manual file when we enter a new line always create a hex file 0D 0A corresponding to "\r\n" But in Rust, just create 0A => "\n" only

So this is the reason why

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.