Stuff ► Code Snippets
You are viewing an old version of the ionflux.org website! Please visit the new version here.

Code Snippets

Here you can find various snippets of source code which I have written and use regularly in my own projects. The snippets provide quick solutions for problems which occur when working without big frameworks (which I often try do). I am quite sure that there are other solutions around. See for yourself if you find them useful, and if you do, feel free to use them in your own projects.

License

You may use the code snippets freely as you like, in modified or unmodified form, whether your project is commercial or not and whichever license it may be released under. Please note that this software is made available in the hope that it will be useful, but WITHOUT ANY WARRANTY AND NO LIABILITY OF THE AUTHOR FOR ANY DAMAGES.

I also do ask that if you use any of this code, you include a notice stating the original author. For example: "This code was originally written by Jörn P. Meier , http://www.ionflux.org/" or "Based on code written by Jörn P. Meier , http://www.ionflux.org/" if there are modifications. This is not required, but would still be very nice. Also, let me know if you use any of this code by writing an e-mail.

Enjoy! :-)

UTF-8 Encoding/Decoding (C++)

UTF-8 is a character encoding which supports an amazing number of characters (the full unicode set) and allows text to be written and transmitted in almost any script of the world, while still maintaining efficiency. It is quickly becoming the standard character encoding on computers as well as in the internet. See here [externer Link] for a detailed explanation of what UTF-8 is and how it works. The code snippets in this section provide encoding/decoding of UTF-8 text strings as well as various utility functions.

[more...]

Hexadecimal Output (C++)

I often want to take a look at data which has been generated by some code I have written, but which is not readable very well by humans. In the worst case, it may even contain characters which are not printable at all. For these situations, I have written some nice little functions which display arbitrary byte data in hexadecimal notation, much like in a hexadecimal editor. It is also possible to view the hexadecimal representation side by side with the readable characters.

[more...]

Data Packing (C++)

For writing data to files or transmitting it over a network, it may be necessary to write functions which pack the data from its native representation in memory into a sequence of bytes. Fortunately, it is not necessary to write a function for each type separately, thanks to C++ templates. The following code snippets illustrate how data can be packed into a string and unpacked from a string without writing specialized functions.

[more...]

© 2006-2007 Jörn P. Meier  •  Impressum  •  Datenschutz  •  Contact: webmaster@ionflux.org  •  Last update: 2009-04-27  •  Version 2.0  •  Language: en | de