ArticleslgStudy

computer science

LHA (file format)

LHA (file format) is a computer science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand LHA (file format) rather than just read about it. In short: LHA or LZH is a freeware compression utility and associated file format. It was created in 1988 by Haruyasu Yoshizaki (吉崎栄泰, Yoshizaki Haruyasu), a medical doctor, and originally named LHarc.

LHA (file format) — main illustration
LHA (file format) — illustration

Key takeaways

  • LHA (file format) belongs to computer science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect LHA (file format) to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of LHA (file format) from memory before moving on to harder problems.

Reference excerpt

LHA or LZH is a freeware compression utility and associated file format. It was created in 1988 by Haruyasu Yoshizaki (吉崎栄泰, Yoshizaki Haruyasu), a medical doctor, and originally named LHarc. A complete rewrite of LHarc, tentatively named LHx, was eventually released as LH. It was then renamed to LHA to avoid conflicting with the then-new MS-DOS 5.0 LH ("load high") command. The original LHA and its Windows port, LHA32, are no longer in development because Yoshizaki is busy at his day job. Although no longer much used in the west, LHA remained popular in Japan until the 2000s. It was used by id Software to compress installation files for their earlier games, including Doom and Quake. Because some versions of LHA have been distributed with source code under a permissive license, LHA has been ported to many operating systems and is still the main archiving format used on Amiga computers, although it competed with LZX in the mid-1990s. This was due to Aminet, the world's largest archive of Amiga-related software and files, standardising on Stefan Boberg's implementation of LHA for the Amiga. Microsoft released the Microsoft Compressed (LZH) Folder Add-on, which was designed for the Japanese version of Windows XP. The Japanese version of Windows 7 ships with the LZH folder add-on built-in. Users of non-Japanese versions of Windows 7 Enterprise and Ultimate can also install the LZH folder add-on by installing the optional Japanese language pack from Windows Update.

Compression methods In an LZH archive, the compression method is stored as a five-byte text string, e.g. -lz1-. These are the third through seventh bytes of the file.

Canonical LZH LHarc compresses files using an algorithm from Yoshizaki's earlier LZHUF product, which was modified from LZARI developed by Haruhiko Okumura (奥村晴彦, Okumura Haruhiko), but uses Huffman coding instead of arithmetic coding. LZARI uses Lempel–Ziv–Storer–Szymanski with arithmetic coding.

lh0 No compression method is applied to the source data. lh1 This method is introduced in LHarc version 1. It supports 4 KiB sliding window, with support for a maximum of 60 bytes of matching length. Dynamic Huffman encoding is used. lh2 lh1 variant. This method supports 8 KiB sliding window, with support for a maximum of 256 bytes of matching length. Dynamic Huffman encoding is used. lh3 lh2 variant with Static Huffman. lh4, lh5, lh6, lh7 Methods 4, 5, 6, 7 support 4, 8, 32, 64 KiB sliding windows respectively, with support for a maximum of 256 bytes of matching length. Static Huffman encoding is used. lh5 is first introduced in LHarc 2, followed by lh6 in LHA 2.66 (MS-DOS), lh7 in LHA 2.67 beta (MS-DOS). LHA itself never compresses into lh4. lhd Technically it is not a compression method, but it is used in .LZH archives to indicate that the compressed object is an empty directory.

Joe Jared extensions Joe Jared extended LZSS to use larger dictionaries.

lh8, lh9, lha, lhb, lhc, lhe Dictionary (sliding window) sizes are 64, 128, 256, 512, 1024, 2048 KiB, respectively. Jared ported LZH to Atari. The fact that lh8 is the same as lh7 was an oversight. Files using larger numbered methods may as well not exist, as Jared only considers them planned features.

UNLHA32 extensions UNLHA32.DLL uses its own method for testing purposes.

lhx It uses 128–256 KiB dictionary.

PMarc extensions These compression methods are created by PMarc, a CP/M archiver created by Miyo. The archive usually has a .PMA extension.

pc1 PopCom compressed executable archive. Details unknown. pm0 No compression method is applied to the source data. pm1 8 KB sliding window, static huffman. Seldom generated, the decompressor is reverse-engineered. pm2 lh5 variant with a 4 KiB sliding window. pms Used to indicate PMarc self-extracting archive. Should be skipped to reveal the real format.

LArc extensions LArc uses the same file format as .LZH, but was written by Kazuhiko Miki, Haruhiko Okumura and Ken Masuyama, with extension name ".LZS". The program seems to have come before LZH. It uses a binary search tree in the LZ matching.

lzs It supports 2 KiB sliding window, with support of maximum 17 bytes of matching length. lz2 It is similar to lzs, except dictionary size and match length can be changed. lz3 Unknown. lz4 No compression method is applied to the source data. lz5 It supports 4 KiB sliding window, with support of maximum 17 bytes of matching length. lz7 lz8 Unknown. Common implementations appear to only support lzs, lz5, plus the storage-only lz4.

Issues

LHICE/ICE There are copies of LHICE marked as version 1.14. According to Okumura, LHICE is not written by Yoshizaki.

Y2K11 bug Because of a bug, DOS time stamps from Level 0 and 1 headers after the year 2011 will be set to 1980, meaning that some utilities need to be patched. This is caused by a bug that interprets the unsigned 7-bit year number bitfield as a 5-bit number. The maximum year should be 2107 instead. The newer Level 2 and 3 headers use a 32-bit Unix time instead. It suffers from the Year 2038 problem.

Header size According to Micco, the author of a popular LHA library, UNLHA32.DLL, many LHA implementations do not check for the length of LHA file headers when reading the archive. Two problems could emerge from this scenario: a buffer-overrun may occur for naive implementations assuming a 4 KB max size from the original specification; antivirus software may skip over files with such large headers and fail to scan for a virus. A similar problem exists with ARJ. Micco reported this problem to Japanese authorities, but they do not consider it a valid vulnerability. Micco went so far to conclude the development of UNLHA32 and advise people to give up on the format. Nevertheless, they came back in 2017 to fix a DLL hijacking issue.

See also

List of archive formats LZX

References

External links A history of data compression in Japan Archived 2006-06-22 at the Wayback Machine LHA Notes Document about LHA. jLHA – LHA library for Java jLHA front-end LHA for Unix Archived 2007-05-28 at the Wayback Machine (in Japanese) Hacking Data Compression Lesson 11 LZH, LZARI, and LZB NSRL Magic File contains PMarc info Explzh Current Windows 7 archiver for LZH/LHA. (Besides LZH it supports RAR, Zip, 7Z, ACE, Tar, Cab & others) lhasa a cross-platform, open source LHA decompressor (+UNLHA32, PMArc, LArc extensions) lzh format document describing LZH header format.

Illustrations

LHA (file format) illustration

Worked examples

Example 1 — a first encounter with LHA (file format)

Start with the simplest possible case. Write down what LHA (file format) claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In computer science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to LHA (file format) before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about LHA (file format) ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of LHA (file format)

In research
LHA (file format) appears in computer science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses LHA (file format) in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
LHA (file format) is common in secondary-school and first-year university syllabi. It links to neighbouring topics 1988 software, Amiga, Archive formats, so understanding it makes those chapters shorter.
In everyday life
Look for LHA (file format) outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “LHA (file format)” →

Affiliate

Preply — study more efficiently by working with a personal tutor. 50% off.

How to study LHA (file format) in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what LHA (file format) means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain LHA (file format) out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is LHA (file format) in simple terms?

LHA or LZH is a freeware compression utility and associated file format. It was created in 1988 by Haruyasu Yoshizaki (吉崎栄泰, Yoshizaki Haruyasu), a medical doctor, and originally named LHarc.

Why does LHA (file format) matter?

Because it connects several computer science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study LHA (file format)?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on LHA (file format).

Tags

  • 1988 software
  • Amiga
  • Archive formats
  • Data compression software
  • File archivers
  • Japanese inventions

Keep exploring