Waitrud Weber’s blog

things and reminders for memories

Language Support: Windows-make: Reading Files: UTF-16( Unicode ): As your Language: Reading keywords files and printed well:

Language Support: Windows-make: Reading Files: UTF-16( Unicode ): As your Language:

Reading keywords files and printed well:

So we could analyze words and do not care about String-Code any like the below:

1. Heis;

2. Sheis;

3. theyare:

---

.\main.cpp  Thu Jul 02 17:55:31 2020

  1 :#include 
  2 :#include 
  3 :
  4 :#include "Print.h"
  5 :#include "array_counter.h"
  6 :#include "parse.h"
  7 :
  8 :int filesize( FILE *fp ) ;
  9 :
 10 :int main () {
 11 :	FILE *fp;
 12 :	int i;
 13 :	char dummy[256];
 14 :	char* filename = ".\\alphabet-001.txt";
 15 :	char* filename_split = ".\\001-split-001.txt";
 16 :	char spit_line[10];
 17 :	char lines[10][10];
 18 :	char basic[3];
 19 :
 20 :	basic[2] = '\0';
 21 :
 22 :	fp = fopen(filename_split, "rb");
 23 :	int file_end = filesize ( fp );
 24 :
 25 :
 26 :
 27 :
 28 :	int start = 0;
 29 :	int j = 0;
 30 :	// first, we are going to find "spit_line".
 31 :	// each block should be stored as block name eve like "001-block---001.txt".
 32 :	// and we care following orders.
 33 :	//
 34 :	for ( i =0; i<file_end; i++ ) {
 35 :		printf("loop start i: %d: j: %d: \r\n", i, j );
 36 :		fread ( dummy, 1, 1, fp);
 37 :
 38 :		dummy[1] = '\0';
 39 :		basic[1] = dummy[0];
 40 :
 41 :		// find line end.
 42 :		if ( m_compare( (char*)basic, (char*)"\r\n" ) == 1 ) {
 43 :			lines[j][i- start - 1 ] = '\0'; //---\r\n if i= 4
 44 :			j++;
 45 :			start = i + 1;
 46 :			//printf("i %d j %d temporary end.\r\n");
 47 :			//exit(-1);
 48 :		} else {
 49 :			lines[j][ i - start ] = dummy[0];
 50 :			lines[j][ i - start + 1 ] = '\0';
 51 :		}
 52 :
 53 :		printf("loop   end i: %d: |%s| j:%d|%s| basic|%s| start:%d\r\n", i, dummy, j, lines[j], basic, start);
 54 :		basic[0] = basic[1];
 55 :	}
 56 :
 57 :	printf("split_line: %s\r\n", spit_line);
 58 :	fclose(fp);
 59 :
 60 :	for ( i =0; i<10; i++ ) {
 61 :		printf("lines[%d]|%s|\r\n", i, lines[i]);
 62 :	}
 63 :
 64 :
 65 :	/*fp = fopen(filename, "rb");
 66 :	file_end = filesize ( fp );
 67 :	for ( i =0; i<file_end; i++ ) {
 68 :		fread ( dummy, 1, 1, fp);
 69 :		dummy[1] = '\0';
 70 :		printf("%d: %s\r\n", i, dummy);
 71 :	}
 72 :
 73 :	close(fp);*/
 74 :	return 0;
 75 :}
 76 :
 77 :int filesize( FILE *fp ) {
 78 :
 79 :	fseek(fp, 0L, SEEK_END);
 80 :	int sz = ftell(fp);
 81 :
 82 :	fseek(fp, 0L, SEEK_SET);
 83 :
 84 :	return sz;
 85 :}
---
loop start i: 0: j: 0:
loop   end i: 0: |-| j:0|-| basic|| start:0
loop start i: 1: j: 0:
loop   end i: 1: |-| j:0|--| basic|--| start:0
loop start i: 2: j: 0:
loop   end i: 2: |-| j:0|---| basic|--| start:0
loop start i: 3: j: 0:
| start:0d i: 3: |
loop start i: 4: j: 0:
loop   end i: 4: |
| j:1|@| basic|
| start:5
loop start i: 5: j: 1:
loop   end i: 5: |(| j:1|(| basic|
(| start:5
loop start i: 6: j: 1:
| start:5d i: 6: |
loop start i: 7: j: 1:
loop   end i: 7: |
| j:2|ー1a| basic|
| start:8
loop start i: 8: j: 2:
loop   end i: 8: |)| j:2|)| basic|
)| start:8
loop start i: 9: j: 2:
| start:8d i: 9: |
loop start i: 10: j: 2:
loop   end i: 10: |
| j:3|.w| basic|
| start:11
split_line: @
lines[0]|---|
lines[1]|(|
lines[2]|)|
lines[3]|.w|
.w・a|4]|d
lines[5]||
lines[6]|・(|
lines[7]|a|
lines[8]||
lines[9]||
---