public static string ReadHCharString(this BinaryReader reader, int count) { return(Hnc2Unicode.hnstring_to_unicodestr(ReadHCharArray(reader, count))); }
private static HwpV3Paragraph Create(BinaryReader reader, HwpV3Paragraph parent) { byte prev_paragraph_shape; ushort n_chars; ushort n_lines; byte char_shape_included; byte flag; int i; prev_paragraph_shape = reader.ReadByte(); n_chars = reader.ReadUInt16(); n_lines = reader.ReadUInt16(); char_shape_included = reader.ReadByte(); reader.ReadBytes(1 + 4 + 1 + 31); // 여기까지 43 바이트 if (prev_paragraph_shape == 0 && n_chars > 0) { reader.ReadBytes(187); } // 빈 문단이면 null 반환 if (n_chars == 0) { return(null); } // 줄 정보 reader.ReadBytes(n_lines * 14); // 글자 모양 정보 if (char_shape_included != 0) { for (i = 0; i < n_chars; i++) { flag = reader.ReadByte(); if (flag == 1) { continue; } reader.ReadBytes(31); } } HwpV3Paragraph p = null; HwpV3Paragraph paragraph = new HwpV3Paragraph(); string @string = String.Empty; // 글자들 ushort n_chars_read = 0; ushort c; while (n_chars_read < n_chars) { c = reader.ReadUInt16(); n_chars_read += 1; if (c == 6) { n_chars_read += 3; reader.ReadBytes(6 + 34); continue; } else if (c == 9) { /* tab */ n_chars_read += 3; reader.ReadBytes(6); @string += "\t"; continue; } else if (c == 10) { /* table */ n_chars_read += 3; reader.ReadBytes(6); /* 테이블 식별 정보 84 바이트 */ reader.ReadBytes(80); ushort n_cells = reader.ReadUInt16(); reader.ReadBytes(2); reader.ReadBytes(27 * n_cells); /* <셀 문단 리스트>+ */ for (i = 0; i < n_cells; i++) { /* <셀 문단 리스트> ::= <셀 문단>+ <빈문단> */ while (true) { p = Create(reader, parent); if (p == null) { break; } paragraph.Add(p); } } /* <캡션 문단 리스트> ::= <캡션 문단>+ <빈문단> */ while (true) { p = Create(reader, parent); if (p == null) { break; } paragraph.Add(p); } continue; } else if (c == 11) { n_chars_read += 3; reader.ReadBytes(6); uint len2 = reader.ReadUInt32(); reader.ReadBytes(344); reader.ReadBytes((int)len2); /* <캡션 문단 리스트> ::= <캡션 문단>+ <빈문단> */ while (true) { p = Create(reader, parent); if (p == null) { break; } paragraph.Add(p); } continue; } else if (c == 13) { /* 글자들 끝 */ @string += Environment.NewLine; continue; } else if (c == 16) { n_chars_read += 3; reader.ReadBytes(6); reader.ReadBytes(10); /* <문단 리스트> ::= <문단>+ <빈문단> */ while (true) { p = Create(reader, parent); if (p == null) { break; } paragraph.Add(p); } continue; } else if (c == 17) { /* 각주/미주 */ n_chars_read += 3; reader.ReadBytes(6); reader.ReadBytes(14); while (true) { p = Create(reader, parent); if (p == null) { break; } paragraph.Add(p); } continue; } else if (c == 18 || c == 19 || c == 20 || c == 21) { n_chars_read += 3; reader.ReadBytes(6); continue; } else if (c == 23) { /*글자 겹침 */ n_chars_read += 4; reader.ReadBytes(8); continue; } else if (c == 24 || c == 25) { n_chars_read += 2; reader.ReadBytes(4); continue; } else if (c == 28) { /* 개요 모양/번호 */ n_chars_read += 31; reader.ReadBytes(62); continue; } else if (c == 30 || c == 31) { n_chars_read += 1; reader.ReadBytes(2); continue; } else if (c >= 0x0020 && c <= 0xffff) { string tmp = new String(Hnc2Unicode.hnchar_to_utf8(c)); @string += tmp; continue; } else { #if DEBUG Trace.WriteLine("Special Character: {0}", ((int)c).ToString("X4")); #endif } /* if */ } paragraph.Text = @string; return(paragraph); }