WO2011060603A1 - 一种txt文件的解码、阅读方法及装置 - Google Patents

一种txt文件的解码、阅读方法及装置 Download PDF

Info

Publication number
WO2011060603A1
WO2011060603A1 PCT/CN2010/000614 CN2010000614W WO2011060603A1 WO 2011060603 A1 WO2011060603 A1 WO 2011060603A1 CN 2010000614 W CN2010000614 W CN 2010000614W WO 2011060603 A1 WO2011060603 A1 WO 2011060603A1
Authority
WO
WIPO (PCT)
Prior art keywords
file
file block
content
page
txt
Prior art date
Application number
PCT/CN2010/000614
Other languages
English (en)
French (fr)
Inventor
常熠
Original Assignee
青岛海信移动通信技术股份有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Priority claimed from CN2009102301638A external-priority patent/CN101763407B/zh
Priority claimed from CN2009102301642A external-priority patent/CN101763408B/zh
Application filed by 青岛海信移动通信技术股份有限公司 filed Critical 青岛海信移动通信技术股份有限公司
Priority to US13/508,390 priority Critical patent/US20120233187A1/en
Publication of WO2011060603A1 publication Critical patent/WO2011060603A1/zh

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F40/00Handling natural language data
    • G06F40/10Text processing
    • G06F40/12Use of codes for handling textual entities
    • G06F40/151Transformation

Definitions

  • the present invention relates to the field of terminal devices, and in particular, to a decoding method of a txt file and an apparatus thereof, and an electronic product including the device, a txt file reading method based on a Brew platform, and a reader thereof. Background technique
  • the current user's requirements for the text reading function of the handheld terminal and the decoding of the txt file are higher and higher, especially the low-end terminal has a file capacity limitation on the operated txt file due to the limitation of the memory size and the like.
  • the existing txt file decoding and e-book applications mainly have the following problems: 1. There is a limitation on the size of the target file, or a slow opening of the large-capacity file. 2. Incomplete analysis of various encodings and different platform text file formats.
  • the embodiments of the present invention are directed to better solving the above problems in the decoding of the txt file of the portable electronic product, and the present invention provides a decoding method of a txt file, an apparatus thereof, and an electronic product including the same;
  • the example is devoted to better solving the above problems in the text reading of handheld terminals, and proposes a txt file reading method based on the Brew platform and its reader.
  • An embodiment of the present invention provides a decoding method of a txt file, where the method further includes the following steps: Step a: Virtually dividing a txt file into a plurality of file blocks according to the set macro value; Step b: According to the sequence of decoding required , sequentially loads the file block and decodes the contents of the file block.
  • the above method further includes step c after step b:
  • the decoded file block is paged and its page table information is saved.
  • Step cl fetch the decoded file block, and convert the content of the file block into Unicode characters
  • Step c2 In the Unicode character of the file block When CR or LF is detected, branch processing is performed.
  • the encoding type of the above txt file includes one or more of the following:
  • the above file blocks are processed in a threaded manner and the thread is terminated after it has been decoded and/or paged and saved.
  • An embodiment of the present invention provides a decoding device for a txt file, where the decoding device includes: a file block processing module: virtually dividing a txt file into a plurality of file blocks according to the set macro value; Content parsing module: The file blocks output by the file block processing module are sequentially loaded and the contents of the file block are decoded in the order in which they are decoded.
  • the above decoding apparatus further includes a content paging module: performing paging processing on the file block decoded by the content analysis module and saving the page table information.
  • the above content paging module also includes the following processing:
  • the decoded file block is taken out and the contents of the file block are converted into Unicode characters; when CR or LF is detected in the Unicode character of the file block, branch processing is performed.
  • the embodiment of the present invention further provides an electronic product, which includes each decoding device according to the second aspect of the embodiment of the present invention.
  • the above electronic products are mobile phones, electronic dictionaries, PDAs, MP3s and MP4s.
  • the beneficial effects of the embodiments of the present invention are:
  • the embodiment of the present invention further solves the size limitation of the text file for the decoding of the existing txt file, and performs adaptive code analysis on the target file without adding any hardware cost.
  • the embodiment of the invention provides a t-file reading method based on the Brew platform, and the method comprises the following steps:
  • Step a According to the set macro value, the txt file is virtually divided into several file blocks; Step b: sequentially loading the file block and decoding the content of the file block according to the reading order;
  • Step c According to the display requirement, the decoded file block is paged and saved, and the page table information is saved;
  • Step d For the page that needs to be read, call the interface function of the Brew platform and display it according to the saved page table information.
  • the method further includes the step e: before the step d;
  • step d If yes, proceed to step d;
  • step b the file block is processed in a thread manner, and the thread is terminated after it completes decoding and paging and saves.
  • Step cl fetch the decoded file block, and convert the content of the file block into Unicode characters
  • Step c2 In the Unicode character of the file block When CR or LF is detected, branch processing is performed.
  • the embodiment of the invention provides a txt file reader based on the Brew platform, and the txt file reader includes:
  • File block processing module According to the set macro value, the txt file is virtually divided into thousands of file blocks;
  • Content parsing module In the order of reading, sequentially input the file block output by the file block processing module and decode the content of the file block;
  • Content paging module According to the display requirement, the file block decoded by the content parsing module is processed by paging and the page table information is saved;
  • Display module For the page that needs to be read, call the interface function of the Brew platform and display it according to the page table information saved by the content paging module.
  • the above reader also includes a display mobile processing module:
  • the page to be read and the page table information of the adjacent page are prepared for the display module at the same time;
  • the content parsing module and the content paging module are first planted into the next file block processing, and then the display module is prepared to read the page and the adjacent page. Page table information.
  • the type of the above txt file can be Windows platform or Apple Mac platform or Linux system type.
  • the embodiment of the present invention provides a mobile communication terminal, which includes each txt file reader described in the second aspect of the embodiment of the present invention.
  • the beneficial effects of the embodiments of the present invention are:
  • the embodiments of the present invention are directed to an existing e-book application,
  • the size limit of the text file is further solved, and the object file is adaptively encoded and parsed and adaptively typeset, which enables the user to operate and use.
  • FIG. 1 is a flowchart of overall processing of a file block according to an embodiment of the present invention
  • FIG. 3 is a flow chart of text layout according to an embodiment of the present invention.
  • FIG. 4a is a schematic diagram of display position movement according to an embodiment of the present invention.
  • Figure 4b is a second schematic view showing the movement of the display position according to the embodiment of the present invention.
  • FIG. 5 is a flow chart showing display position movement according to an embodiment of the present invention.
  • Figure 6 is a flow chart showing the text display of the embodiment of the present invention.
  • FIG. 7 is a structural diagram of a first embodiment of a decoding apparatus according to an embodiment of the present invention.
  • FIG. 8 is a structural diagram of a second embodiment of a decoding apparatus according to an embodiment of the present invention.
  • FIG. 9 is a structural diagram of a first embodiment of a reader according to an embodiment of the present invention.
  • FIG. 10 is a block diagram showing a second embodiment of a reader in accordance with an embodiment of the present invention. detailed description
  • the embodiment of the present invention provides a decoding method of a txt file, a device thereof, and an electronic product including the device.
  • the embodiment of the present invention provides a txt file reading method based on the Brew platform and a reader thereof.
  • File Block A file fragment that is divided into segments of a set size for analysis, that is, only virtual partitioning, does not change the size and structure of the original file.
  • Virtual paging Each time you press the set maximum number of lines that can be displayed for paging, and save the corresponding page information, it is not necessarily the same as the actual displayed page.
  • Cache Store the page table information in the segment in the pre-allocated file after reading the file segment. In space, this program life cycle is always defined as a cache for fast read and write storage.
  • FIG. 1 is a flowchart showing the overall processing of a file block according to an embodiment of the present invention. As shown in FIG. 1, step 100 starts, and the file size information is read, and fi le-s ize-Getf i les ize O.
  • step 104 a thread Creat-thread is created, and the thread Ini t_thread is initialized to start analyzing the content of the file block Thread-start.
  • step 106 a file block is read from the preset offset, and start-pos i t ion is the defined offset parameter, then Read_block (start-posi t ion).
  • step 108 the content of the file block is analyzed, that is, the text content is decoded; then, the page is processed by the paging processing function Block-pagescale O, and the page table information is memorized to the global variable, that is, saved by Mock_offset_reci te ().
  • the page table information includes the page start offset and the page length.
  • the paging is finally completed by the Fini sh_pagingscale () function.
  • step 110 after the file block analysis is completed, and the page table information is also ready, the event notification is sent to the upper layer to be displayed, SendEvent ().
  • step 112 after the file block operation is completed, the thread is released, that is, Release-thread 0.
  • the decoding method of the txt file in the embodiment of the present invention basically includes the following steps: Step a: According to the set macro value (the size of which can be IK-1M, mainly according to the hardware), the txt file is virtually divided into Several file blocks.
  • Step b The file blocks are sequentially loaded and the contents of the file blocks are decoded in the order in which they are decoded.
  • Step a According to the set macro value (the size can be 1K-1M, mainly according to the hardware situation Fixed), the txt file is virtually divided into several file blocks.
  • Step b The file blocks are sequentially loaded and the contents of the file blocks are decoded in the order of reading.
  • Step c According to the display requirement (mainly including the maximum number of lines displayed per page, the number of displayable pixels associated with the display screen and the size of the display font, etc.), the decoded file block is paged and its page table information is Save it.
  • the display requirement mainly including the maximum number of lines displayed per page, the number of displayable pixels associated with the display screen and the size of the display font, etc.
  • Step d For the page that needs to be read, call the interface function of the Brew platform and display it according to the saved page table information.
  • the decoding speed needs to be independent of the file capacity, and the reading speed needs to be independent of the file capacity. Therefore, depending on the platform used, the macro value of the file block can be defined each time. Different terminals can set the size of the macro value according to their own hardware and software configuration.
  • step 200 begins by reading the contents of the file block and returning the read content to the pointer.
  • step 200 begins by reading the contents of the file block and returning the read content to the pointer.
  • step 202 the file block content is read from the file block start offset for decoding.
  • the embodiment of the present invention adopts an Un code.
  • step 206 a byte judgment is further performed on the converted code, that is, Chars-judgement (Ret). If a break code is encountered in the byte judgment, the process proceeds to step 208, where If the error code is not encountered in the byte judgment, the process proceeds to step 212, and the success information is returned, indicating that the entire segment is successfully parsed, and the page processing is continued.
  • Chars-judgement Chars-judgement
  • step 208 the process proceeds to step 210, where one byte is offset backwards and forwards from the parsing for secondary parsing, that is, the Pcontent pointer is automatically incremented or decremented by 1, then returns to step 204, re-analyzed, and executed. step.
  • Unicode, unicode-BE and utf-8 encoding files have corresponding flag bits in the file header (that is, the first few bytes of the file), so the encoding format can be encoded according to the corresponding content read by the file header. Judge, then make the appropriate conversions as needed. Bit, so the parsing of the read content requires the control and judgment of the code value, especially for the function that can jump arbitrarily, it is likely to cause the code break problem, that is, the start position of the clip after the jump is located exactly in a Chinese character code.
  • the lower digit (for example: “medium” is represented in the GB code by two bytes as “D6 D0" (both in hexadecimal notation), and the meaning here is exactly read as DO, that is, the word in front of it.
  • DO the word in front of it.
  • the section "D6” is omitted, which causes all the code values in the following text to be misaligned, thus causing the problem of code breakage, which is manifested as garbled display.
  • the embodiment of the present invention performs adaptive fine-tuning decoding after reading any text segment.
  • the ASCI I code value is represented by a single byte
  • the non-ASCI I code characters such as Chinese characters adopt a double-byte flag
  • the double-byte has a certain rule: the high-order byte range is 80-FE.
  • the low byte range is 40-FE.
  • the embodiment of the present invention selects to move forward by one byte, and then seamlessly joins the read content with the previous segment.
  • the above decoding process reads a certain block of text for paging, and adopts the thread design. Therefore, the flexible jump in the processing can be well controlled, and the variable control problem caused by the segmentation time-sharing loop is avoided.
  • step 300 starts, and the page content is extracted by the page table information, and the page table of the page start position Page-start and the page character number Page_char_num is specified.
  • step 306 the page character is judged.
  • the process proceeds to step 308, and the automatic branch is performed as a segment, and whether the character offset is performed at the beginning of the paragraph according to the need (that is, the so-called first line) Indent mode), the specific operation is to add the segment character to the line list, the content of which includes the target linked list, the row start address and the number of line bytes, ie Add. l ink (PI ink, l ine-s tart, l ine.cnt), then return to step 306 to re-process and perform the subsequent steps.
  • PI ink PI ink, l ine-s tart, l ine.cnt
  • step 306 when CR or LF is not detected, the process proceeds to step 310 to determine whether the end is detected, and the judgment is judged only once at the end of the page.
  • step 312 the branch ends, that is, Finish-scale (PI ink), and the PI ink pointer is transmitted to the global variable.
  • step 314 the page row list is established, and an event is sent to notify the upper layer to display, that is, SendEvent 0.
  • the typesetting problem of the text is relatively critical for the full-screen or non-full-screen free switching and changing of the font style size that the mobile terminal often uses.
  • the typesetting takes full account of the different text character storage rules used by different pc platforms. Adaptive processing is performed in a targeted manner, mainly referring to the representation of row switching.
  • the text of the Windows platform uses “CR+LF”, the Apple Mac system only uses “CR,,, and the Linux operating system uses "LF,,” so the line-feed format that needs to generate text for different systems is unified and implemented when parsing text. Fully adaptive.
  • a linked list is used to memorize each line of content that the terminal needs to display, similar to the processing of page table information, so that the related processing of the display can be specific to the line, which is convenient for reading mode during reading. Free switching and other diverse operations.
  • the text layout processing in the technical solution of the embodiment of the present invention is similar to the function realization of "automatic line feed" in the text reader in the pc end, so that the text can be automatically displayed on the screen automatically for the current screen width, thereby eliminating the excessive length of the paragraph. Problems such as incomplete display, or the need to scroll through the scroll bar.
  • FIGS 4a, 4b are schematic diagrams showing the movement of the display position according to the embodiment of the present invention.
  • the black-edged window is the text content currently displayed on the screen, and the three display segments are respectively three texts loaded into the memory. information.
  • the above moves include two ways of moving:
  • the display of the page between the file blocks moves.
  • This is collectively referred to herein as a display segment, which means that the display segment can represent different file blocks, or it can represent different pages within a file block.
  • the header fragment information needs to be dried, and the information chain of the next segment is added after the tail segment, and the original tail segment is set as the intermediate segment, the original intermediate segment is set as the header segment, and the newly added trailer is set to the tail segment. Fragment. This ensures that each display content has overlapping information with the middle segment, that is, the entire process is always in a state where the context is not empty.
  • the above processing is actually to ensure that each time the page turning or turning action is performed, the line information of the content to be displayed on the next page can be directly read.
  • FIG. 5 is a flow chart showing the movement of the display position according to the embodiment of the present invention. As shown in FIG. 5, the processing is more completely illustrated.
  • the Link node contains:
  • the starting position of the pointer of the text content of the line is a pText
  • nCurrentCnt Link-GetCount (&m_UneLiiik
  • pNewPageLink PageLoad (m-pNext, nPageOff set, nPageCnt); ⁇ Load the next page of content, and return the page row information content to the linked list
  • the starting position of the current page display will be as shown in Figure 4a, and the row node of the starting position is m_pCurrentNode.
  • Idisplay_setclip Pdisplay, position
  • Idisplay-drawtext Pdisplay, Pnode-text
  • step 606 after the force word is high, Position-position+Font-Height, the canvas pointing position is moved to the bottom of the font, that is, Idisplay-moveto (Pdisplay, position) ⁇
  • step 608 an underline or the like is displayed according to requirements, that is, Idisplay-Drawl ine (Pdi splay).
  • the function interface function of the Qualcomm BREW platform is invoked by the font display, etc., so that the application can completely realize the display function of the text theme, and the user-defined font can be displayed by adopting various display settings. Color and background color, support for additional formatting requirements such as underline and dashed lines.
  • the common interface function of the display font can be drawn on the corresponding position of the screen. When drawing each line, additional processing can be performed according to the currently displayed attachment content. If the current line needs to display an underline, it will be corresponding after the font is displayed. The line is drawn below the position by the Brew common interface function.
  • FIG. 7 is a structural diagram of a first embodiment of a decoding apparatus according to an embodiment of the present invention.
  • the decoding apparatus includes: a file block processing module and a content parsing module, wherein
  • the file block processing module virtually divides the txt file into a plurality of file blocks according to the set macro value.
  • the content parsing module sequentially loads the file blocks output by the file block processing module and decodes the contents of the file blocks in the order in which they are decoded.
  • FIG. 8 is a structural diagram of a second embodiment of a decoding apparatus according to an embodiment of the present invention.
  • the decoding apparatus includes: a file block processing module, a content parsing module, and a content paging module, where: the file block processing module is configured according to The fixed macro value divides the txt file into several file blocks.
  • the content parsing module sequentially loads the file blocks output by the file block processing module and decodes the contents of the file blocks in the order in which they are decoded.
  • the content paging module performs paging processing on the file block decoded by the content analysis module according to the display requirement and saves the page table information.
  • FIG. 9 is a structural diagram of a first embodiment of a reader according to an embodiment of the present invention, as shown in FIG.
  • the reader includes: a file block processing module, a content parsing module, a content paging module, and a display module, wherein:
  • the file block processing module virtually divides the txt file into a plurality of file blocks according to the set macro value.
  • the content parsing module sequentially loads the file blocks output by the file block processing module and decodes the contents of the file blocks in the order in which they are decoded.
  • the content paging module performs paging processing on the file block decoded by the content analysis module according to the display requirement and saves the page table information.
  • the display module calls the interface function of the Brew platform for the page to be read and displays it according to the page table information saved by the content paging module.
  • the content paging module in Figure 7, Figure 8, and Figure 9 above also includes the following processing:
  • the decoded file block is taken out and the contents of the file block are converted into Unicode characters; when CR or LF is detected in the Unicode character of the file block, branch processing is performed.
  • the type of the above txt file can be Windows platform or Apple Mac platform or Linux system type.
  • the types of decoding by the content parsing module include one or more of the following:
  • the reader includes: a file block processing module, a content analysis module, a content paging module, a display movement processing module, and a display module.
  • the file block processing module virtually divides the txt file into a plurality of file blocks according to the set macro value.
  • the content parsing module sequentially loads the file blocks output by the file block processing module in the order of reading and decodes the contents of the file blocks.
  • the content paging module performs paging processing on the file block decoded by the content analysis module according to the display requirement and saves the page table information.
  • Displaying the mobile processing module when the starting position of the page to be read does not exceed the content range of the currently read file block, simultaneously preparing the page to be read and the page table information of the adjacent page to the display module;
  • the content parsing module and the content paging module are first planted into the next file block processing, and then the display module is prepared to read the page and the adjacent page. Page table information.
  • the display module calls the interface function of the Brew platform for the page to be read and displays it according to the page table information saved by the content paging module.
  • the above content paging module also includes the following processing:
  • the decoded file block is taken out and the contents of the file block are converted into Unicode characters; when CR or LF is detected in the Unicode character of the file block, branch processing is performed.
  • the type of the above txt file can be Windows platform or Apple Mac platform or Linux system type.
  • the types of decoding by the content parsing module include one or more of the following:
  • the technology design is based on not limiting the size of the target file, while the opening speed is independent of the file size, and supports the requirements for display and typesetting of multiple styles, and the processing structure is innovated, such as to implement arbitrary txt text files.
  • the parsing and typographic functions which switch the font size according to the interrupt support font, change the basic functions such as font color and background color, and also support the user's diversified operations on file browsing.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Health & Medical Sciences (AREA)
  • Artificial Intelligence (AREA)
  • Audiology, Speech & Language Pathology (AREA)
  • Computational Linguistics (AREA)
  • General Health & Medical Sciences (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Document Processing Apparatus (AREA)

Description

一种 txt文件的解码、 阅读方法及装置 技术领域
本发明实施例涉及终端设备领域, 尤其涉及一种 txt文件的解码方法及其 装置及包括该装置的电子产品, 一种基于 Brew平台的 txt文件阅读方法及其阅 读器。 背景技术
当前用户对于手持终端的文本阅读功能以及对 txt 文件解码的要求越来 越高, 尤其是中低端终端由于内存大小等限制往往对操作的 txt 文件有文件 容量限制。
一方面, 超过终端硬件、 便携式电子产品硬件的限制则无法对 txt文件 进行解码、 阅读等操作, 需要用户自行切割成多个文件才能进行解码、 阅读 等操作, 这给用户的使用造成了不便; 另一方面, 在当前信息量激增的背景 下, txt文件的容量越来越大, 包含的信息量越来越多, 对于这类大容量文件 的阅读要求越来越迫切; 同时, 由于文件容量的增大, 对于用户进行翻页, 跳转等操作的多样性也越来越多, 所以传统的 txt文件阅读方法及其阅读器、 txt 文件解码方法及其解码装置的应用已无法满足当前及今后用户的基本要 求和常用操作。
再者, 当前终端类电子书应用的第三方软件已有不少, 但绝大多数基于 java平台的第三方软件; 并且, 这些软件对文件也有上述的限制和功能缺陷, 而针对 Brew平台的电子书应用更加匮乏。
另外, 不同的系统生成的 txt文件也会有差别。 当前主要以 Windows 系 统、 苹果 Mac系统以及 Linux系统为主, 其生成的文本字符存储规则均不相 同, 这就造成了 txt文件在系统平台间移植时不能充分识别的问题。
总的来说, 现有 txt文件解码、 电子书应用主要存在以下一些问题: 1、 对目标文件的大小存在限制, 或对大容量文件的打开较慢等问题。 2、 对各种编码及不同平台文本文件格式的不完全解析。
并且, 针对电子书应用还存在以下问题:
3、 无法调节显示效果, 如字体大小、 前景及背景颜色、 下划线等多样显 示模式以及随意的跳转浏览, 因此无法对阅读文件进行多样化操作处理。 发明内容
有鉴于此, 本发明实施例致力于更好的解决便携电子产品 txt 文件的解 码中存在的上述问题, 提出了一种 txt 文件的解码方法及其装置及包括该装 置的电子产品; 本发明实施例致力于更好的解决手持终端文本阅读中存在的 上述问题, 提出了一种基于 Brew平台的 txt文件阅读方法及其阅读器
本发明实施例提供了一种 txt文件的解码方法, 该方法还包括如下步骤: 步骤 a: 依据设定的宏值, 对 txt文件虚拟划分为若干个文件块; 步骤 b: 按照需要解码的顺序,依次载入文件块并对所述文件块的内容进 行解码。
上述方法在步骤 b之后还包括步驟 c:
对解码后的文件块进行分页处理, 并对其页表信息进行保存。
上述步骤 c中对解码后的文件块进行分页处理前还包括如下步骤: 步驟 cl: 取出解码后的文件块, 并将文件块的内容转化为 Unicode字符; 步骤 c2: 在文件块的 Unicode字符中检测到 CR或 LF时, 均进行分行处 理。
上述 txt文件的编码类型包括以下几种中的一种或多种:
GB2312/GBK, Unicode, uincode-BE、 utf-8。
上述文件块釆用线程方式进行处理, 并在其完成解码和 /或分页并保存后 结束线程。
本发明实施例提供了一种 txt文件的解码装置, 该解码装置包括: 文件块处理模块: 依据设定的宏值, 将 txt 文件虚拟划分为若干个文件 块; 内容解析模块: 按照需要解码的顺序, 依次载入文件块处理模块输出的 文件块并对文件块的内容进行解码。
上述解码装置还包括内容分页模块: 对内容解析模块解码后的文件块进 行分页处理并对其页表信息进行保存。
上述内容分页模块还包括如下处理:
取出解码后的文件块, 并将文件块的内容转化为 Unicode字符; 在文件块的 Unicode字符中检测到 CR或 LF时, 均进行分行处理。
本发明实施例还提供了一种电子产品, 该电子产品包括本发明实施例第 二方面所述的各解码装置。
上述电子产品为手机、 电子词典、 PDA、 MP3和 MP4。
本发明实施例的有益效果是: 本发明实施例针对已经存在的 txt 文件的 解码, 进一步解决了文本文件的大小限制, 同时对目标文件进行了自适应编 码解析, 不增加任何硬件成本。
本发明实施例提供了一种基于 Brew平台的 t文件阅读方法, 该方法包 括如下步骤:
步骤 a: 依据设定的宏值, 对 txt文件虚拟划分为若干个文件块; 步骤 b: 按照阅读的顺序,依次载入文件块并对所述文件块的内容进行解 码;
步骤 c: 依据显示需求,对解码后的文件块进行分页处理并对其页表信息 进行保存;
步驟 d: 对需要阅读的页面, 调用 Brew平台的接口函数并根据保存的页 表信息进行显示。
上述方法在步骤 c之后, 在步骤 d之前还包括步骤 e: 围;
若是, 则进入步骤 d;
若否, 返回步骤 b并重新执行后续步骤< 上述步骤 b开始, 对所述文件块采用线程方式进行处理, 并在其完成解 码及分页并保存后结束线程。
上述步骤 c中对解码后的文件块进行分页处理前还包括如下步骤: 步骤 cl: 取出解码后的文件块, 并将文件块的内容转化为 Unicode字符; 步骤 c2: 在文件块的 Unicode字符中检测到 CR或 LF时, 均进行分行处 理。
本发明实施例提供了一种基于 Brew平台的 txt文件阅读器, 该 txt文件 阅读器包括:
文件块处理模块: 依据设定的宏值, 将 txt 文件虛拟划分为若千个文件 块;
内容解析模块: 按照阅读的顺序, 依次栽入文件块处理模块输出的文件 块并对文件块的内容进行解码;
内容分页模块: 依据显示需求, 对内容解析模块解码后的文件块进行分 页处理并对其页表信息进行保存;
显示模块: 对需要阅读的页面, 调用 Brew平台的接口函数并根据内容分 页模块保存的页表信息进行显示。
上述阅读器还包括显示移动处理模块:
当需要阅读的页面的起始位置不超出当前阅读的文件块的内容范围时, 同时给显示模块准备需要阅读的页面及相邻页面的页表信息;
当需要阅读的页面的起始位置超出当前阅读的文件块的内容范围时, 先 由内容解析模块和内容分页模块栽入下一个文件块处理后再给显示模块准备 要阅读的页面及相邻页面的页表信息。
上述 txt文件的类型可为 Windows平台或苹果 Mac平台或 Linux系统类 型。
本发明实施例提供了一种移动通信终端, 该移动通信终端包括本发明实 施例第二方面所述的各 txt文件阅读器。
本发明实施例的有益效果是: 本发明实施例针对已经存在的电子书应用, 进一步解决了文本文件的大小限制, 同时对目标文件进行了自适应编码解析 及自适应排版功能, 可以使用户多样化操作和使用。 附图说明
图 1是本发明实施例的文件块整体处理流程图;
图 2是本发明实施例的自适应解码流程图;
图 3是本发明实施例的文字排版流程图;
图 4a是本发明实施例的显示位置移动示意图之一;
图 4b是本发明实施例的显示位置移动示意图之二;
图 5是本发明实施例的显示位置移动流程图;
图 6是本发明实施例的文本显示流程图;
图 7是本发明实施例解码装置的第一实施例结构图;
图 8为本发明实施例解码装置的第二实施例结构图;
图 9是本发明实施例阅读器的第一实施例结构图;
图 10是本发明实施例阅读器的第二实施例结构图。 具体实施方式
为了解决 txt 文件的解码中的容量及解码速度的问题, 本发明实施例提 供了一种 txt文件的解码方法及其装置及包括该装置的电子产品。
为了解决手持终端文本阅读中存在的容量限制及阅读速度受限的问题, 本发明实施例提供了一种基于 Brew平台的 txt文件阅读方法及其阅读器。
首先来说明一下本发明实施例的技术术语。
文件块: 将文件分成设定大小的片段进行分析的文件片段, 也就是只进 行虚拟分块, 并不改变原文件的大小和结构。
虚拟分页: 每次按设定的可以显示的最大行数进行分页, 并保存相应的 页信息, 与实际显示的页不一定相同。
Cache: 每次读取文件片段后将该片段内的页表信息存储于事先分配好的 空间中, 这段程序生命周期始终作为快速读写的存储区定义为 Cache。
接下来, 结合各附图分多个小部具体说明 txt文件的解码方法及其装置、 txt文件阅读方法及其阅读器, 其中, 具体的函数以及操作均以伪码表示。
图 1示出本发明实施例的文件块整体处理流程图,如图 1所示, 步骤 100 开始, 读取文件大小信息开始, fi le-s ize-Getf i les ize O。
步骤 102中, 根据定义的宏值 Fragment-size, 分析计算文件块的数量, Frags=f i le_s ize/Fragment-s ize+l。
步骤 104中, 创建线程 Creat-thread, 并初始化线程 Ini t_thread,以开 始分析文件块的内容 Thread- start。
步棘 106 中, 从预设偏移量开始读取一个文件块, start-pos i t ion 为 定义的偏移量参数, 则 Read—block (start—posi t ion)。
步骤 108 中, 分析该文件块内容, 即对文本内容进行解码; 然后进行分 页, 由分页处理函数 Block-pagescale O进行处理, 并记忆页表信息到全局变 量, 即由 Mock_offset_reci te ()进行保存。 其中, 页表信息包括页始偏移量 和页长度。 并由 Fini sh_pagingscale ()函数最终完成分页。
步骤 110 中, 文件块分析完毕后, 并且页表信息也已准备好, 发事件通 知上层准备显示, SendEvent ()。
步骤 112中, 完成该文件块操作后#放线程, 即 Release-thread 0。 由上可知本发明实施例 txt文件的解码方法基本包括如下步骤: 步驟 a: 依据设定的宏值(其大小可以为 IK- 1M, 主要根据硬件的情况而 定), 对 txt文件虚拟划分为若干个文件块。
步骤 b: 按照需要解码的顺序,依次载入文件块并对所述文件块的内容进 行解码。
由上可知本发明实施例基于 Brew平台的 txt文件阅读方法基本包括如下 步骤:
步骤 a: 依据设定的宏值(其大小可以为 1K-1M, 主要根据硬件的情况而 定), 对 txt文件虛拟划分为若干个文件块。
步骤 b: 按照阅读的顺序,依次载入文件块并对所述文件块的内容进行解 码。
步骤 c: 依据显示需求 (主要包括每页显示的最大行数, 其相关到显示屏 的可显示像素点数和显示字体的大小等), 对解码后的文件块进行分页处理并 对其页表信息进行保存。
步骤 d: 对需要阅读的页面, 调用 Brew平台的接口函数并根据保存的页 表信息进行显示。
针对硬件对文件大小有相应限制的情况, 同时又达到解码速度需要与文 件容量无关、 读取速度需要与文件容量无关, 故根据使用平台的不同, 可以 定义每次读取文件块的宏值。 不同终端可以根据自身的软硬件配置, 设置宏 值的大小。
每次读取时针对高通平台的特点, 可以使用线程进行操作, 避免使用较 长时间的循环导致底层其他任务超时引起的异常。
每次解析相应文本片段的内容, 需要将该段内容进行虚拟分页处理, 并 将每块的起始绝对位置存储于 cache中, 以便每次读取时无需再次重新解析, 并最小化对终端的 cache容量大小需求。
图 2示出本发明实施例的自适应解码流程图, 如图 2所示, 步骤 200开始, 读取文件块内容, 并把读到的内容返回给指针。 定义指针 Pcontent , 使 Pcontent=Read_block (s tart-pos i t ion)。
步骤 202中, 从文件块始偏移量开始读取文件块内容, 以进行解码。
步骤 204中, 判断编码格式并根据编码格式进行解码, 即判断编码格式函 数进行判断 Ntype=Get_codingtype (Pcontent), 然后由解码函数进行解码 Ret=Coding_convent ion (Ntype, Pcontent) , 也即进行转码转换成统一的码 型, 本发明实施例采用 Un i code码。
步骤 206 中 , 进一步对转换后 的码进行字 节判 断 , 即 Chars- judgement (Ret),如果在字节判断中遇到断码, 则进入步骤 208中, 返 回错误信息 error; 如果在字节判断中没有遇到断码, 则进入步骤 212中, 返 回 success信息, 说明整段解析成功, 继续分页处理。
在步骤 208之后, 进入步骤 210, 从解析处向后向前偏移一个字节进行二 次解析, 也即 Pcontent指针自动加 1或减 1 , 然后返回步骤 204中, 重新进行解 析, 并执行后续步骤。
针对文本文件编码方式的不同, 需要对每一片段进行解码时需要进行码 转换过程, 由于国内常用的编码方式有 GB2312/GBK, Unicode, uincode-BE, utf-8等, 针对含有非 ASCI I字符的编码格式各有不同。
由于采用 Unicode, unicode-BE及 utf- 8编码方式的文件在文件头部 (即 文件最开始的几个字节)有相应的标志位, 所以可以根据文件头读取的相应 内容进行编码格式的判断, 然后根据需要进行相应的转化。 位, 所以对于读取内容的解析需要加以码值的控制和判断, 尤其是对于可以 任意跳转的功能很可能导致断码问题, 即跳转后的片段起始位置正好位于一 个中文字符编码的低位(例如: "中"在 GB码通过两个字节表示为 "D6 D0" (均 为 16进制表示), 这里所表述的意思为恰好读取为 DO,也就是将其前面的一个 字节 "D6" 漏掉), 从而引起后文的码值全部错位, 因此导致了断码问题, 表 现出来均为乱码显示。
针对上述编码问题, 本发明实施例在读取任意文本片段后进行了自适应 的微调解码。
根据 GB码的编码规则可以知道, ASCI I码值采用单字节表示, 汉字等非 ASCI I码字符采用双字节标志, 而双字节有一定的规则: 高位字节范围是 80-FE, 低位字节范围是 40-FE。
另外基于文本中两类编码长度的字符的穿插问题(即普通文本必有标点 符号等 ASCI I字符, 如换行符等, 或如果没有相应的符号则所有内容均变为了 双字节编码文本, 紧需要判断偏移量是否为偶数即可), 在解码时完全可以根 据读取位置的前后两个字节进行多种可能性判断。 如果无法判断, 则可以往 后读取一定内容直到遇到相应的 ASCI I字符, 即可以确定是否解码错误, 如果 解码有误, 则说明遇到断码。 紧需要将起始位置向后或向前移动一个字节即 可解决当前断码问题。
本发明实施例为了实现文本的无缝衔接, 选择采用向前移动一个字节, 然后将所读取内容与前一片段进行无缝衔接。
上述解码过程在读取某一文本块进行分页, 采用了线程的设计, 所以对 于处理中的灵活跳转可以很好的进行控制, 避免了分段分时循环造成的变量 控制问题。
接下来, 就分行处理为主说明本发明实施例技术方案中文字排版的处理 过程。
图 3示出本发明实施例的文字排版流程图, 如图 3所示, 步骤 300开始, 通过页表信息取出页面内容, 在明确了页起始位置 Page-start 和页字符数 Page_char_num 等页表信息后, 就可以通过内容指针取得页面内容, 即 Pcontent=Read-content (Page-start, Page_char-num)。
步骤 302 中, 将页面编码转化为 Unicode字符统一处理, 即由转码函数 PUnicode=code_convert ion (Pcontent, Ntype)。
步骤 304中, 分行处理开始, 初始化行链表, Pl ink=Ini t— l ink ()。
步骤 306中, 对页面字符进行判断, 当检测到 CR或 LF时, 进入步驟 308 中, 作为一段进行自动分行, 并可根据需要是否在段落开始处进行字符偏移 (即通常所说的首行缩进模式), 其具体操作是把该段字符加入到行链表中, 其 内 容 包 括 目 标 链表 、 行起 始 地 址 和 行 字 节 数 , 即 Add. l ink (PI ink, l ine-s tart, l ine.cnt), 然后返回步骤 306中重新进行处理 并执行后续步骤。
步骤 306中, 当没有检测到 CR或 LF时, 进入步骤 310中, 判断是否检 测到结尾, 并且该判断只会在页面尾部判断一次。
步骤 312中, 分行结束, 即 Finish—scale (PI ink) ,同时把 PI ink指针传 送给全局变量, 步骤 314 中, 该页行链表建立完毕, 发事件通知上层进行显示, 即 SendEvent 0 .
由于本发明实施例针对灵活的显示设置进行处理, 所以对于移动终端经 常采用的全屏或非全屏的自由切换及改变字体样式大小等要求, 文字的排版 问题是比较关键的。
排版时充分考虑到不同 pc平台采用的文本字符存储规则不同。 针对性的 进行了自适应处理, 主要是指行切换的表示。 Windows 平台的文本采用 "CR+LF" , 苹果 Mac系统的仅使用 "CR,,, 而 Linux操作系统采用 "LF,,, 所 以需要对不同系统生成文本的换行格式在解析文本时进行统一并实现充分自 适应。
同时, 为了更好的显示, 采用了链表对终端需要显示的每一行内容进行 了记忆, 类似于页表信息的处理, 这样显示的相关处理就可以具体到行, 方 便在阅读过程中对阅读模式自由切换以及进行其他多样化操作。
本发明实施例的技术方案中文字排版处理类似于 pc 端中文本阅读器中 "自动换行" 的功能实现, 使文本可以针对当前屏幕宽度自动完整显示于屏 幕中, 免去了段落过长导致的显示不全等问题, 或需要滚动条进行拖动的操 作。
而针对字体的变换, 仅仅需要在字符串测量函数中更改字体大小即可, 因此, 在分页过程完全做到了对字体大小的去相关化。
图 4a、 4b示出本发明实施例的显示位置移动示意图, 如图 4a、 4b所示, 黑边窗口为当前显示在屏幕的文本内容, 三个显示片段分别为一次载入内存 的三个文本信息。
这里只保存着分行后的行偏移量信息, 并非将实际的文本块内容栽入; 每次上下行滚动或翻页时将当前阴影窗口向前后移动。
上述的移动包括两种移动方式:
其一, 文件块内的页面之间的显示移动;
其二, 文件块之间页面的显示移动。 在此统称为显示片段, 也就是说显示片段可以是代表不同文件块, 也可 以代表一个文件块内的不同页面。
接下来从总体上说明显示片段的切换过程:
当阴影窗口移动到上图状态时, 即阴影窗口的起始位置已不在中间文本 显示片段的内时, 需要进行显示片段切换。
具体来说, 需要将头片段信息幹放, 并在尾片段后补充下一片段的信息 链, 并将原尾片段置为中间片段, 原中间片段置为头片段, 而新添加的片尾 置为尾片段。 这样就保证了每次显示内容均处与中间片段有交叠信息, 即整 个过程始终处于上下文非空的状态。
上述处理实际是为了保证每次的翻页或翻行动作执行时, 可以直接读取 下一页需要显示内容的行信息。
这样也避免了传统操作中对于片段解码后向前翻滚即向前翻页或向前翻 行时容易出现乱码的问题。 因为对于非 ASCII码字符的众多编码方式大多是 与 ASCII 的编码长度不一致, 因此向前读取文本内容时容易出现编码判断失 误导致的断码问题, 从而引起相应的乱码问题。
图 5示出本发明实施例的显示位置移动流程图, 如图 5所示, 较完整的 示意该处理过程。
首先, 定义三个 buffer, 分别为:
m_pPrev (代表 Part I中的文本);
ipMiddle (代表 Part II中的文本);
m— pNext (代表 Part II I中的文本);
及行链表: Link * ni-LineLink, m_pCurrentNode。
Link节点中存有:
1、 该行文本内容的指针起始位置一 pText;
2、 该行的行字节数 --- nLength。
假定当前终端每页可以显示的行数为 LINE-PER-PAGE; 以及
Link相关的操作函数统一以 Link-开头。 该部分的几个重要处理过程为:
A、
nCurrentCnt = Link-GetCount (&m_UneLiiik
得到当前链表中的行数;
B、
如果当前链表中的内容不够现实三页(假定当前处于文本中段, 没有显示 到尾部), 需要补充内容。
If (nCurrentCnt < 2 * LINE -PER -PAGE)
{
Uintl6 nPageOff set, nPageCnt;
〃定义临时变量以便取得页的起始偏移位置及字符数
Link * pNewPageLink;
〃新载入页面的行信息指针
GetNextPagelnfo (&nPage0f f set, &nPageCnt);
〃取得下一页内容的起始偏移位置及该页所含字符数
pNewPageLink = PageLoad (m-pNext, nPageOff set, nPageCnt); 〃将下一页内容载入, 并将该页行信息内容形成链表返回
Link— Add (&m_XineLink, pNewPageLink);
〃将当前取得的新页的行 添加到全局链 部
}
C、
将设当前页显示的起始位置如图 4a 所示, 且该起始位置所在行节点为 m_pCurrentNode。
假如现向后翻页, 则页面位置状态会变成图 4b:
可以看到, 下一页内容暂时无法显示完全, 故需要在翻页前将 Part I部 分释放掉, 并将 Part II 及 Part III顺次前移为 Part I及 Part II , 最后 在载入下一页, 将其添加到链表中, 并将相关变量内容设置到适当的当前位 置。
具体流程如下:
If (FALSE =β JudgeLinkLef t m-LineLink, m_pCurrentNode))
{
FreeHeadPart (&iUneUiik, LINE.PER-PAGE)
〃将链表中 part I部分的节点释放掉
Free-Buffer (ra-pPrev)
〃将 Part I部分的内容指针释放
MoveBuffer-To.Lef t (m_pPrev, m.pMiddle, m-pNext)
〃左移緩存区指针
〃载入下一页具体过程见 B部分
}
m-pCurrentNode = UnkGetNext (&iLineLink, LI E -PER -PAGE)
〃从当前节点往后移动一页行数的节点数, 得到下一页开始显示的节点 位置
Display (&iLineLink, m_pCurrentNode)
〃从 pCurrentNode所指位置开始显示下一页内容, 具体 Display函数实 现已分析过.
图 6示出本发明实施例的文本显示流程图, 如图 6所示, 步骤 600开始, 取出页链表指针, 即 Plink=Get_page_link(),从头节点读链表。
步骤 602中, 读取链表节点,即 Pnode= Get-link-start (Plink) β 步骤 604中, 画布指向位置移动到该行位置,
Idisplay_setclip (Pdisplay, position) ,其中, position初始化值为 0; Idisplay-drawtext (Pdisplay, Pnode-text)。
步骤 606中, 力口字高后, Position- position+Font- Height,画布指向位 置移动到字体底部, 即 Idisplay-moveto (Pdisplay, position) β
步 骤 608 中 , 根 据 要 求 显 示 下 划 线 等 内 容 , 即 Idisplay-Drawl ine (Pdi splay)。
步骤 610中, 判断是否读取到链表下一节点,即 Pnode=Get_next (Pl ink, Pnode) , 如果是, 则返回步骤 604中, 重新移动并执行后续步驟; 如果不是, 则进入步骤 612中, 该页显示完毕, 结束上述过程。
在本发明实施例中,由于字体显示等调用高通 BREW平台的功用接口函数, 使得该应用完全可以将文字主题的显示功能全部实现, 并可采用多样化的显 示设置, 可以显示用户自定义的字体颜色及背景颜色, 同时支持下划线、 虚 线等附加格式的显示要求。
由于在对文件块解析时已经将内容解码并储存行链表中, 所以需要从哪 一行的位置开始显示仅仅需要将起始位置置于对应链表的节点处, 然后根据 显示区域大小对每一行调用 Brew显示字体的公共接口函数画于屏幕的对应位 置即可, 在对每一行进行绘制时, 可以根据当前设置的附件显示内容进行额 外的处理, 如当前行需要显示下划线, 则在显示字体后将对应位置下方通过 Brew公共接口函数绘制直线。
图 7示出本发明实施例解码装置的第一实施例结构图, 如图 7所示, 该 解码装置包括: 文件块处理模块和内容解析模块, 其中
文件块处理模块依据设定的宏值, 将 txt文件虚拟划分为若干个文件块。 内容解析模块按照需要解码的顺序, 依次栽入文件块处理模块输出的文 件块并对文件块的内容进行解码。
图 8示出本发明实施例解码装置的第二实施例结构图, 如图 8所示, 该 解码装置包括: 文件块处理模块、 内容解析模块以及内容分页模块, 其中: 文件块处理模块依据设定的宏值, 将 txt文件虚拟划分为若干个文件块。 内容解析模块按照需要解码的顺序, 依次载入文件块处理模块输出的文 件块并对文件块的内容进行解码。
内容分页模块依据显示需求, 对内容解析模块解码后的文件块进行分页 处理并对其页表信息进行保存。
图 9示出本发明实施例阅读器的第一实施例结构图, 如图 9所示, 该阅 读器包括: 文件块处理模块、 内容解析模块、 内容分页模块以及显示模块, 其中:
文件块处理模块依据设定的宏值, 将 txt文件虚拟划分为若干个文件块。 内容解析模块按照需要解码的顺序, 依次载入文件块处理模块输出的文 件块并对文件块的内容进行解码,
内容分页模块依据显示需求, 对内容解析模块解码后的文件块进行分页 处理并对其页表信息进行保存。
显示模块对需要阅读的页面, 调用 Brew平台的接口函数并根据内容分页 模块保存的页表信息进行显示。
上述图 7, 图 8, 图 9中的内容分页模块还包括如下处理:
取出解码后的文件块, 并将文件块的内容转化为 Unicode字符; 在文件块的 Unicode字符中检测到 CR或 LF时, 均进行分行处理。
上述 txt文件的类型可为 Windows平台或苹果 Mac平台或 Linux系统类 型。
上述内容解析模块解码的类型包括以下几种中的一种或多种:
GB2312/GB , Unicode, uincode-BE> utf - 8。
图 10示出本发明实施例阅读器的第二实施例结构图,如图 10所示,该阅 读器包括: 文件块处理模块、 内容解析模块、 内容分页模块、 显示移动处理 模块和显示模块。
文件块处理模块依据设定的宏值, 将 txt文件虛拟划分为若干个文件块。 内容解析模块按照阅读的顺序, 依次载入文件块处理模块输出的文件块 并对文件块的内容进行解码。
内容分页模块依据显示需求, 对内容解析模块解码后的文件块进行分页 处理并对其页表信息进行保存。
显示移动处理模块, 当需要阅读的页面的起始位置不超出当前阅读的文 件块的内容范围时, 同时给显示模块准备需要阅读的页面及相邻页面的页表 信息; 当需要阅读的页面的起始位置超出当前阅读的文件块的内容范围时, 先 由内容解析模块和内容分页模块栽入下一个文件块处理后再给显示模块准备 要阅读的页面及相邻页面的页表信息。
显示模块对需要阅读的页面, 调用 Brew平台的接口函数并根据内容分页 模块保存的页表信息进行显示。
上述内容分页模块还包括如下处理:
取出解码后的文件块, 并将文件块的内容转化为 Unicode字符; 在文件块的 Unicode字符中检测到 CR或 LF时, 均进行分行处理。
上述 txt文件的类型可为 Windows平台或苹果 Mac平台或 Linux系统类 型。
上述内容解析模块解码的类型包括以下几种中的一种或多种:
GB2312/GBK, Unicode^ uincode-BE, utf - 8。
针对当前便携电子产品(包括手机、 电子词典、 PDA、 MP3和 MP4等)、 移 动终端中电子书应用的使用越来越频繁, 及当前信息量的不断增加, 对于目 前不同平台的便携电子产品、 基于 BREW平台的手机终端中, 尤其是中低端手 机对于文本文件解码限制较多、 文本文件电子书的阅读限制较多, 并且功能 不够完善; 传统的直接栽入并解码排版的方式已经不适应当前的应用需求, 并且对用户的多样化操作支持不够完善。 该技术将解决终端对文本文件阅读 的容量大小限制, 并支持如对各种编码格式的自适应, 自动优化排版, 及任 意跳转, 翻页等操作。
针对上述问题, 该技术设计基于不限制目标文件大小, 同时打开速度对 与文件大小无关, 并支持对多样式的显示及排版等要求, 进行了处理结构的 创新, 实现了诸如对任意 txt 文本文件的解析和排版功能, 根据中断支持字 库切换字体大小, 更改字体颜色及背景颜色等基本功能, 同时也支持用户对 文件浏览的多样化操作。
以上对本发明实施例的具体描述旨在说明具体实施方案的实现方式, 不 能理解为是对本发明实施例的限制。 本领域普通技术人员在本发明实施例的 教导下, 可以在详述的实施方案的基础上做出各种变体, 这些变体均应包舍 在本发明实施例的构思之内。 本发明实施例所要求保护的范围仅由所迷的权 利要求书进行限制,

Claims

权 利 要 求
1. 一种 txt文件的解码方法, 包括如下步骤:
步骤 a: 依据设定的宏值, 对 txt文件虚拟划分为若干个文件块; 步骤 b:按照需要解码的顺序,依次载入文件块并对所述文件块的内容进 行解码。
2. 如权利要求 1所述的 txt文件的解码方法, 其特征在于, 在步骤 b之 后还包括步骤 c:
对解码后的文件块进行分页处理, 并对其页表信息进行保存。
3. 如权利要求 1或 2所述的 txt文件的解码方法, 其特征在于, 所述步 骤 c中对解码后的文件块进行分页处理前还包括如下步骤:
步骤 cl : 取出解码后的文件块,并将文件块的内容转化为 Unicode字符; 步骤 c2: 在文件块的 Unicode字符中检测到 CR或 LF时, 均进行分行处 理。
4. 如权利要求 3所述的 txt文件的解码方法, 其特征在于, 所述 txt文 件的编码类型包括以下几种中的一种或多种:
GB2312/GBK, Unicode, uincode-BE、 utf-8。
5. 如权利要求 4所述的 txt文件的解码方法, 其特征在于:
所述文件块采用线程方式进行处理, 并在其完成解码和 /或分页并保存后 结束线程。
6. —种基于 Brew平台的 txt文件阅读方法, 包括如下步骤:
步骤 a: 依据设定的宏值, 对 txt文件虚拟划分为若干个文件块; 步骤 b: 按照阅读的顺序,依次载入文件块并对所述文件块的内容进行解 码;
步骤 c:依据显示需求,对解码后的文件块进行分页处理并对其页表信息 进行保存;
步骤 d: 对需要阅读的页面, 调用 Brew平台的接口函数并根据保存的页 表信息进行显示。
7. 如权利要求 6所述的 txt文件阅读方法,其特征在于,在步骤 c之后, 在步骤 d之前还包括步骤 e: 围;
若是, 则进入步骤 d;
若否, 返回步骤 b并重新执行后续步骤。
8. 如权利要求 6或 7所述的 txt文件阅读方法, 其特征在于, 所述步骤 b开始,对所迷文件块采用线程方式进行处理, 并在其完成解码及分页并保存 后结束线程.
9. 如权利要求 8所述的 txt文件阅读方法, 其特征在于, 所述步骤 c中 对解码后的文件块进行分页处理前还包括如下步骤:
步骤 cl: 取出解码后的文件块, 并将文件块的内容转化为 Unicode字符; 步骤 c2: 在文件块的 Unicode字符中检测到 CR或 LF时, 均进行分行处 理。
10. 如权利要求 9所述的 txt文件阅读方法, 其特征在于, 所述步骤 d 中调用的 Brew平台的接口函数包括以下类别中的一个或多个:
字体颜色、 背景颜色、 下划线、 虛线。
11. 一种 txt文件的解码装置, 包括:
文件块处理模块: 依据设定的宏值, 将 txt 文件虛拟划分为若干个文件 块;
内容解析模块: 按照需要解码的顺序, 依次载入文件块处理模块输出的 文件块并对文件块的内容进行解码。
12. 如权利要求 11所述的 txt文件的解码装置, 其特征在于, 还包括内 容分页模块: 对内容解析模块解码后的文件块进行分页处理并对其页表信息 进行保存。
13. 如权利要求 12所述的 txt文件的解码装置, 其特征在于, 所述内容 分页模块还包括如下处理:
取出解码后的文件块, 并将文件块的内容转化为 Unicode字符; 在文件块的 Unicode字符中检测到 CR或 LF时, 均进行分行处理。
14. 一种电子产品, 其特征在于:
包括权利要求 11或 12或 13所述的解码装置。
15. 如权利要求 14所述的电子产品, 其特征在于:
所述电子产品为手机、 电子词典、 PDA、 MP3和 MP4。
16. 一种基于 Brew平台的 t文件阅读器, 包括:
文件块处理模块: 依据设定的宏值, 将 txt 文件虛拟划分为若干个文件 块;
内容解析模块: 按照阅读的顺序, 依次载入文件块处理模块输出的文件 块并对文件块的内容进行解码;
内容分页模块: 依据显示需求, 对内容解析模块解码后的文件块进行分 页处理并对其页表信息进行保存;
显示模块: 对需要阅读的页面, 调用 Brew平台的接口函数并根据内容分 页模块保存的页表信息进行显示。
17. 如权利要求 16所述的 txt文件阅读器, 其特征在于, 还包括显示移 动处理模块:
当需要阅读的页面的起始位置不超出当前阅读的文件块的内容范围时, 同时给显示模块准备需要阅读的页面及相邻页面的页表信息;
当需要阅读的页面的起始位置超出当前阅读的文件块的内容范围时, 先 由内容解析模块和内容分页模块载入下一个文件块处理后再给显示模块准备 要阅读的页面及相邻页面的页表信息。
18. 如权利要求 16或 17所述的 txt文件阅读器, 其特征在于, 所述内 容分页模块还包括如下处理:
取出解码后的文件块, 并将文件块的内容转化为 Unicode字符; 在文件块的 Unicode字符中检测到 CR或 LF时, 均进行分行处理。
19. 如权利要求 16或 17所述的 txt文件阅读器, 其特征在于, 所述内 容解析模块解码的类型包括以下几种中的一种或两种或多种:
GB2312/GB , unicode、 uincode-BE、 utf-8。
20. 一种移动通信终端, 其特征在于包括权利要求 16或 17所述的 txt 文件阅读器。
PCT/CN2010/000614 2009-11-19 2010-04-30 一种txt文件的解码、阅读方法及装置 WO2011060603A1 (zh)

Priority Applications (1)

Application Number Priority Date Filing Date Title
US13/508,390 US20120233187A1 (en) 2009-11-19 2010-04-30 Method and apparatus for decoding and reading txt file

Applications Claiming Priority (4)

Application Number Priority Date Filing Date Title
CN200910230164.2 2009-11-19
CN2009102301638A CN101763407B (zh) 2009-11-19 2009-11-19 一种基于Brew平台的txt文件阅读方法及其阅读器
CN200910230163.8 2009-11-19
CN2009102301642A CN101763408B (zh) 2009-11-19 2009-11-19 txt文件的解码方法与其装置及包括该装置的电子产品

Publications (1)

Publication Number Publication Date
WO2011060603A1 true WO2011060603A1 (zh) 2011-05-26

Family

ID=44059194

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2010/000614 WO2011060603A1 (zh) 2009-11-19 2010-04-30 一种txt文件的解码、阅读方法及装置

Country Status (2)

Country Link
US (1) US20120233187A1 (zh)
WO (1) WO2011060603A1 (zh)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR101625785B1 (ko) 2012-04-16 2016-05-30 지티이 코포레이션 이동 단말 정보 보안 관리 방법, 장치 및 이동 단말

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US8839102B2 (en) * 2010-11-30 2014-09-16 International Business Machines Corporation Method to automatically display filenames encoded in multiple code sets
US10949617B1 (en) * 2018-09-27 2021-03-16 Amazon Technologies, Inc. System for differentiating encoding of text fields between networked services
CN109683969A (zh) * 2018-12-21 2019-04-26 深圳市中科亿信技术有限公司 一种VxWorks操作系统的终端显示方法及装置

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1834854A (zh) * 2005-03-16 2006-09-20 富士通株式会社 用于呈现信息的装置及其方法
CN101145159A (zh) * 2007-10-16 2008-03-19 吕利勇 提供可分解阅读原版媒体内容的系统、方法及播放装置
CN101615175A (zh) * 2009-08-11 2009-12-30 深圳市五巨科技有限公司 一种读取移动终端电子书的系统和方法

Family Cites Families (22)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2683022B2 (ja) * 1988-04-13 1997-11-26 株式会社日立製作所 データ秘匿方式
US5422736A (en) * 1991-03-22 1995-06-06 Canon Kabushiki Kaisha Multi-mode image processing permitting selection of quantization process according to image characteristics
US6272190B1 (en) * 1992-03-12 2001-08-07 Ntp Incorporated System for wireless transmission and receiving of information and method of operation thereof
FR2723795B1 (fr) * 1994-08-16 1996-10-25 France Telecom Dispositif et procede de securisation d'un document et code graphique d'authentification.
JP3226426B2 (ja) * 1994-09-27 2001-11-05 松下電器産業株式会社 半導体メモリ及びその使用方法並びに画像プロセッサ
US5734881A (en) * 1995-12-15 1998-03-31 Cyrix Corporation Detecting short branches in a prefetch buffer using target location information in a branch target cache
US5818533A (en) * 1996-08-08 1998-10-06 Lsi Logic Corporation Method and apparatus for decoding B frames in video codecs with minimal memory
US5903282A (en) * 1997-07-28 1999-05-11 Lsi Logic Corporation Video decoder dynamic memory allocation system and method with an efficient freeze mode
US5926227A (en) * 1997-07-28 1999-07-20 Lsi Logic Corporation Video decoder dynamic memory allocation system and method with error recovery
US6072548A (en) * 1997-07-28 2000-06-06 Lsi Logic Corporation Video decoder dynamic memory allocation system and method allowing variable decoded image size
US6298425B1 (en) * 1999-01-12 2001-10-02 Compaq Computer Corp. Computer disk management system using doublet A-B logging
JP2000278142A (ja) * 1999-03-23 2000-10-06 Toshiba Video Products Japan Kk デジタルデータ記録再生装置
KR100597411B1 (ko) * 2004-08-04 2006-07-05 삼성전자주식회사 파일의 효율적인 데이터 관리를 위한 방법 및 장치
US7334209B1 (en) * 2004-10-15 2008-02-19 Xilinx, Inc. Method and system for generating multiple implementation views of an IC design
US7284227B1 (en) * 2004-10-15 2007-10-16 Xilinx, Inc. Method and system for generating implementation files from a high level specification
EP1936508B1 (en) * 2005-09-22 2019-07-03 Panasonic Corporation Information recording medium access apparatus, and data recording method
US8392174B2 (en) * 2006-08-07 2013-03-05 International Characters, Inc. Method and apparatus for lexical analysis using parallel bit streams
US7783862B2 (en) * 2006-08-07 2010-08-24 International Characters, Inc. Method and apparatus for an inductive doubling architecture
US20080040345A1 (en) * 2006-08-07 2008-02-14 International Characters, Inc. Method and Apparatus for String Search Using Parallel Bit Streams
US20080033974A1 (en) * 2006-08-07 2008-02-07 International Characters, Inc. Method and Apparatus for XML Parsing Using Parallel Bit streams
KR101236477B1 (ko) * 2008-12-22 2013-02-22 한국전자통신연구원 비대칭 클러스터 파일 시스템의 데이터 처리 방법
US8271558B1 (en) * 2009-02-26 2012-09-18 Symantec Corporation Creating a unification directory that unifies a plurality of file system directories

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1834854A (zh) * 2005-03-16 2006-09-20 富士通株式会社 用于呈现信息的装置及其方法
CN101145159A (zh) * 2007-10-16 2008-03-19 吕利勇 提供可分解阅读原版媒体内容的系统、方法及播放装置
CN101615175A (zh) * 2009-08-11 2009-12-30 深圳市五巨科技有限公司 一种读取移动终端电子书的系统和方法

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR101625785B1 (ko) 2012-04-16 2016-05-30 지티이 코포레이션 이동 단말 정보 보안 관리 방법, 장치 및 이동 단말

Also Published As

Publication number Publication date
US20120233187A1 (en) 2012-09-13

Similar Documents

Publication Publication Date Title
CN101763407B (zh) 一种基于Brew平台的txt文件阅读方法及其阅读器
US5793381A (en) Unicode converter
US5682158A (en) Code converter with truncation processing
US9940744B2 (en) Remote font management
US5784069A (en) Bidirectional code converter
US8756527B2 (en) Method, apparatus and computer program product for providing a word input mechanism
US8122353B2 (en) Composing a message in an online textbox using a non-latin script
CN103678267B (zh) 一种图文混合内容的排版和渲染方法及系统
US5784071A (en) Context-based code convertor
US20050041011A1 (en) Method and user interface for entering text
JP2009545064A (ja) フォントサブセッティングのための方法と装置
US9158742B2 (en) Automatically detecting layout of bidirectional (BIDI) text
US7383553B2 (en) Accessing a platform independent input method editor from an underlying operating system
WO2011060603A1 (zh) 一种txt文件的解码、阅读方法及装置
CN101763408B (zh) txt文件的解码方法与其装置及包括该装置的电子产品
WO2016027482A1 (ja) プリンタ、印刷システムおよび印刷制御方法
CN104424192A (zh) 形成多字型字库、通过该字库显示不同字型的方法及装置
KR20220099953A (ko) 동적 조판
CN109992221A (zh) 一种用于矢量字库运算的处理器芯片的实现方法
JP4451908B2 (ja) ユニコード・コンバータ
WO1997010556A1 (en) Unicode converter
WO1997010556A9 (en) Unicode converter
CN1869889A (zh) 电子设备中正反序排列语言混合输入的方法
KR20100021817A (ko) 텍스트 데이터 압축 방법
CN105893335B (zh) 显示文本的方法和装置

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 10831019

Country of ref document: EP

Kind code of ref document: A1

WWE Wipo information: entry into national phase

Ref document number: 13508390

Country of ref document: US

NENP Non-entry into the national phase

Ref country code: DE

32PN Ep: public notification in the ep bulletin as address of the adressee cannot be established

Free format text: NOTING OF LOSS OF RIGHTS PURSUANT TO RULE 112(1) EPC (EPO FORM 1205N DATED 26/07/2012)

122 Ep: pct application non-entry in european phase

Ref document number: 10831019

Country of ref document: EP

Kind code of ref document: A1