https://github.com/aftersol/convendian
C Library for converting endianness
https://github.com/aftersol/convendian
c endian endianess endianness
Last synced: about 2 months ago
JSON representation
C Library for converting endianness
- Host: GitHub
- URL: https://github.com/aftersol/convendian
- Owner: Aftersol
- License: unlicense
- Created: 2025-03-03T22:02:24.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2026-03-14T09:10:34.000Z (3 months ago)
- Last Synced: 2026-03-14T19:46:37.548Z (3 months ago)
- Topics: c, endian, endianess, endianness
- Language: C
- Homepage: https://aftersol.github.io/convEndian/
- Size: 298 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Endian Conversion Library
A library for converting between endianness that doesn't depend on external libraries.
Place ```conv_endian.c``` and ```conv_endian.h``` into your source files
The library can be optionally be built by calling make or using CMake
## Downloads
[You can download the source code for the library here: https://github.com/Aftersol/convEndian/releases](https://github.com/Aftersol/convEndian/releases)
---
## Examples
### Reading big endian data
```c
//...
// receive data
char yourBuffer[512];
int* ptr_to_buffer = (int*)yourBuffer;
int value;
// read big endian
fread(yourBuffer, sizeof(int), 1, yourfile);
value = *ptr_to_buffer;
// to be converted and store in whatever endian your machine runs on
value = read_be_u32(value);
//...
```
### Writing big endian data
```c
//...
// write or send data
// to be converted into big endian value
int value = 1234567890;
value = convert_to_be_u32(value);
// write big endian integer
fwrite(&value, sizeof(int), 1, yourfile);
//...
```