(Reporter) how to compare the text produced in windows and liunx? (SOC) (nc-OpenGL) (VCS) (ultraedit)

Source: Internet
Author: User
Tags linux text editor ultraedit

Abstract
Verify whether the RTL result is equivalent to the representation described in C or Matlab.AlgorithmSimilarly, we often dump the result of the comparison between the two-dimensional learning language, but what is the difference between using ultracompare and zookeeper?

Introduction
Environment: Visual Studio 2010 + NC-OpenGL 5.4 + ultraedit 13.10a + 2

This article will discuss the following topics:

1. Differences between Windows and Linux text formats

2. Why is the result of using ultraedit to open a Linux text editor different from that of notepad?

3. How to Use ultracompare to compare the text formats generated in Windows and Linux?

4. Conclusion

Differences between Windows and Linux text formats

In this example, we use the C language of Visual Studio 2010 and the nc-OpenGL (DOS version, but because it is transplanted from the Linux version, therefore, the generated text records are in the Linux format) and the text records of the same content are different from those of the results.

Simple_text.c/C

 1   /*   
2 (C) oomusou 2011 Http://oomusou.cnblogs.com
3
4 Filename: simple_text.c
5 Compiler: Visual C + + 10.0
6 Description: simple text
7 Release: jun.15, 2011 1.0
8   */
9
10 # Include < Stdio. h >
11
12   Int Main (){
13 File * FP;
14 Int I;
15
16 Fp = Fopen ( " Simple_text.txt " , " W " );
17 For (I = 0 ; I < 2 ; I ++ )
18 Fprintf (FP, " % 1D \ n " , I );
19
20 Fclose (FP );
21 }

Results

 
0
1

Simple_text.v/OpenGL

 1   /*   
2 (C) oomusou 2011 Http://oomusou.cnblogs.com
3
4 Filename: simple_text.v
5 Simulator: NC-OpenGL 5.4
6 Description: simple text
7 Release: jun.15, 2011 1.0
8   */
9
10   Module Simple_text_tb;
11
12 Integer FP;
13 Integer I;
14
15 Initial Begin
16 Fp = $ Fopen ( " Simple_text.txt " );
17
18 For (I = 0 ; I < 2 ; I = I + 1 )
19 $ Fwrite (FP, " % 1D \ n " , I );
20
21 $ Fclose (FP );
22 End
23
24 Endmodule

Results

 
0
1

In theory, these two texts should be exactly the same. In Windows, we use NotePad to open the texts produced by C, it seems like using gedit in Linux to enable the text token generated by the kernel.

However, if you use ultraedit to use hex edit (-> ), the difference between the two is displayed:

Use ultraedit to open the text produced by C.

 

Use ultraedit to enable the text token generated by using Tilde.

The difference between the two is that ultraedit will clearly tell you whether it is a DoS or Unix character, in addition to the content of the text watermark itself (the hexadecimal value of 0 is 0x30, and 1 is 0x31 ), the difference between the remaining two rows is different in the rows of rows.

In Windows, the Delimiter is 0x0d and 0x0a, that is, Cr (carriage return) and LF (new line feed) are used as the delimiter.

In Linux, The Delimiter is 0x0a, that is, LF (new line feed) is used as the delimiter.

This creates a very interesting phenomenon. If you use the notepad of windows to open the text editor of Linux, you will find that the lines cannot be written, (because there is no Cr), it is normal to go To the Linux gedit to enable the character encoding function in Windows (because there is lf ), however, if we use ultracompare to compare the two texts, the comparison is different, because ultracompare is to use the binary method to decode the comparison, that is to say, whether the value of each byte in the case of 2 is the same, rather than the internal content.

Why is the result of using ultraedit to open a Linux text editor different from that of notepad?

Maybe you will say, "I used ultraedit to open a Linux text editor, and the instructions are normal, there has never been a problem !! 』

Let's take a look at the settings of ultraedit:

Go to details> organization> case handling> DOS/Unix/Mac

This is the default setting value of ultraedit, detect file type and prompt to change, which is why when you use ultraedit to open a Linux text editor, all of them will be shown below

However, when you press "yes" or "no", the result of the statement is the same, because only recognize dos terminated lines (CR/LF) as new lines for editing settings are not checked, that is, you are a Linux text editor. In the end, ultraedit will still be displayed in Windows text editor mode.

The suggestion is changed to the following settings:

Set UNIX/MAC file detection/conversion to none, so that the prompt window will not appear when Linux text is opened.

Select only recognize dos terminated lines (CR/LF) as new lines for editing, so that the display of ultraedit will be consistent with that of notepad, as soon as we see that the content is not correct, we know that it is a Linux text handler.

How to Use ultracompare to compare the text formats generated in Windows and Linux?

Step 1: Convert Linux text into DoS

Case study-> strongswan-> UNIX/MAC to DoS

Change the firmware to the DOS format.

 

Memory.

Step 2: Use ultracompare to compare the limit case (omitted)

 

Download the complete program
Simple_text_c.7z (Text Example of Windows generated by C)
Simple_text_verilog.7z)

Conclusion
This is a small issue that RTL verification often encounters. Due to lack of understanding about the Windows and Linux text formats, coupled with the configuration of ultraedit, it is often known that the result is correct, but the result of the use of ultacompare comparison is always incorrect because of the incorrect settings.

In addition, we can also know that for text editors of the same content, Windows text scripts are different from Linux text scripts because Windows uses Cr and LF lines, two bytes are required. Linux kernel requires lf bytes, and only one byte is required. The size of the fixed Linux text encoding case is small.

the full text is complete.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.