All Projects → thomaslevesque → HumanBytes

thomaslevesque / HumanBytes

Licence: Apache-2.0 License
A library to convert byte sizes to a human readable form

Programming Languages

C#
18002 projects
Batchfile
5799 projects

Projects that are alternatives of or similar to HumanBytes

xbytes
Parse bytes to human readable sizes (4747) → ('4.75 KB') and vice versa.
Stars: ✭ 17 (-39.29%)
Mutual labels:  bytes, human, size
Filesize.js
JavaScript library to generate a human readable String describing the file size
Stars: ✭ 997 (+3460.71%)
Mutual labels:  bytes, size
Compressed Size Action
GitHub Action that adds compressed size changes to your PRs.
Stars: ✭ 300 (+971.43%)
Mutual labels:  bytes, size
composer-cost
Displays cost/size of each composer package installed.
Stars: ✭ 31 (+10.71%)
Mutual labels:  size
bytes-java
Bytes is a utility library that makes it easy to create, parse, transform, validate and convert byte arrays in Java. It supports endianness as well as immutability and mutability, so the caller may decide to favor performance.
Stars: ✭ 120 (+328.57%)
Mutual labels:  bytes
php-binary
A PHP library for parsing structured binary streams.
Stars: ✭ 30 (+7.14%)
Mutual labels:  bytes
octet
A library that makes working with bytebuffers painless.
Stars: ✭ 79 (+182.14%)
Mutual labels:  bytes
next-size
Next.js plugin to print browser assets sizes
Stars: ✭ 39 (+39.29%)
Mutual labels:  size
BitByteData
Read and write bits and bytes in Swift.
Stars: ✭ 21 (-25%)
Mutual labels:  bytes
jeelizPupillometry
Real-time pupillometry in the web browser using a 4K webcam video feed processed by this WebGL/Javascript library. 2 demo experiments are included.
Stars: ✭ 78 (+178.57%)
Mutual labels:  size
fade
A Simulation Framework for Auditory Discrimination Experiments
Stars: ✭ 12 (-57.14%)
Mutual labels:  human
express-keenio
📊 Rapidly install analytics with a middleware.
Stars: ✭ 42 (+50%)
Mutual labels:  human
bundlemon
Monitor your bundle size
Stars: ✭ 53 (+89.29%)
Mutual labels:  size
x86-Assembly-Reverse-Engineering
🛠 Knowledge about the topic of x86 assembly & disassembly 🛠
Stars: ✭ 27 (-3.57%)
Mutual labels:  bytes
HRM Software
Human resource management C# based with SQL database desktop software.
Stars: ✭ 22 (-21.43%)
Mutual labels:  human
diskusage
FANTASTIC SPEED utility to find out top largest folders/files on the disk.
Stars: ✭ 64 (+128.57%)
Mutual labels:  size
iOSThin
iOS瘦身方案
Stars: ✭ 25 (-10.71%)
Mutual labels:  size
rulid.rs
Rust Universally Unique Lexicographically Sortable Identifier
Stars: ✭ 40 (+42.86%)
Mutual labels:  bytes
humanapi
The easiest way to integrate health data from anywhere - https://www.humanapi.co
Stars: ✭ 21 (-25%)
Mutual labels:  human
GetSTFolderSize
Get folder sizes blazingly fast with PowerShell
Stars: ✭ 41 (+46.43%)
Mutual labels:  size

HumanBytes

NuGet version AppVeyor build AppVeyor tests

A library to convert byte sizes to a human readable form.

Installation

Install the library via NuGet

PM> Install-Package HumanBytes

Basic usage

The Bytes extension method returns an object that has a human readable string representation:

var f = new FileInfo("TheFile.jpg");
Console.WriteLine("The size of '{0}' is {1}", f, f.Length.Bytes());

The value is formatted using the default formatter; you can change the default formatter settings through the ByteSizeFormatter.Default static property.

More advanced usage

If you need more control, create an instance of ByteSizeFormatter and change its settings:

var formatter = new ByteSizeFormatter
{
    Convention = ByteSizeConvention.Binary,
    DecimalPlaces = 1,
    NumberFormat = "#,##0.###",
    MinUnit = ByteSizeUnit.Kilobyte,
    MaxUnit = ByteSizeUnit.Gigabyte,
    RoundingRule = ByteSizeRounding.Closest,
    UseFullWordForBytes = true,
};

var f = new FileInfo("TheFile.jpg");
Console.WriteLine("The size of '{0}' is {1}", f, formatter.Format(f.Length));

Localization

At this stage, HumanBytes only supports English and French. However, if you need support for another language, it's very easy, as there are only 3 terms that need to be translated. Just create an instance of ByteSizeFormatter as shown above, and set the following properties:

  • ByteSymbol: the symbol for byte, e.g. "B" in English.
  • ByteWord: the word for byte, e.g. "byte" in English.
  • BytesWord: the word for several bytes, e.g. "bytes" in English.

The values set on these properties will be used instead of the ones defined in resources.

If you would like to add permanent support for another language, you'll have to modify the library itself. Just clone the project, add a Resources.xx.resx file (where xx is the language code) in the HumanBytes/Properties folder, translate the terms, and build.

I'll be glad to accept pull requests to support more languages.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].