2.1.2.2 check_convert_CR_str_to_CRLF


Description

Convert all "\n" end-of-lines sequences to "\r\n" in a string.

Syntax

bool check_convert_CR_str_to_CRLF( string & str )

Parameters

str
[modify]a reference to the string to convert.

Return

Returns true if string changed otherwise false.

Examples

EX1

int check_convert_CR_str_to_CRLF_ex1()
{ 
    //convert \n to \r\n 
    string str = "hello\ngoodbye";
    bool bRet = check_convert_CR_str_to_CRLF(str);
    
    if( bRet && 0 == strcmp(str, "hello\r\ngoodbye") )
    	printf("convert successfully");
    else
    	printf("fail to convert");

    return 0;
}

Remark

See Also

Header to Include

origin.h

Reference