Questions tagged [converting]
Converting involves changing data from one data type or format to another.
376 questions
5votes
1answer
118views
Replacement for 'enum class' with string functionality
Because I think maintainability can be done better with strings instead of plain enumerator-values when doing fstream IO, I wanted a replacement struct in my project that behaves like an ...
2votes
0answers
161views
PHP Parser and converter - SOLID and DRY
I am working on a PHP application that transforms data from the input CSV (JSON, TXT, or XML) into an output CSV (JSON or database, for example). The output format differs from the input: some columns ...
8votes
1answer
770views
library for converting numbers to HEX
This is library for fast converting "HEX strings" to unsigned numbers and vice versa. The result is not defined, if input is incorrect, e.g. string "ZZZ1" will be converted to ...
2votes
1answer
67views
How better methods of remaking the code by array without changing its functionality, and performance but reducing amount by ~10 times
Can anybody help me with examples of code? How is the approach to optimize code relative to my example with using "switch case" to "arrays"? Without changing its functionality, but ...
0votes
1answer
293views
WordPress Plugin for WebP/AVIF Image Conversion
I'm looking for feedback on a WordPress plugin I developed for automatically converting images to WebP and AVIF formats. The goal is to optimize image loading performance. The plugin has the following ...
1vote
1answer
105views
safe numeric type converter
I have written a function for casting between built in numeric types. I built it to check if the source value is within the range of the destination value, and to provide a nicely legible error if not....
1vote
1answer
294views
C++ arbitrary base convertor
This is my second C++ program. Again, I wrote it all by myself. I only started learning C++ yesterday. The concept of the program is simple; it should read input from ...
4votes
2answers
489views
fast convert string_view to floating point
The code makes following assumptions: std::string_view is not null-terminated there are no exponents, all floating point inputs are in the way 123.123 limiting ...
1vote
0answers
87views
Python script that turns a gigantic text file into an IP geolocation database
I have written a Python script that turns a gigantic text file into a SQLite3 database. The text file is truly gigantic, it is 133MiB or 140,371,572 bytes in size, and contains 140,371,572 characters ...
5votes
1answer
722views
Python script that identifies the country code of a given IP address
This is a Python script I wrote to identify the country code of a given IP address, using data obtained from tor. It uses geoip.txt to identify country code for IPv4 addresses, and geoip6.txt to do so ...
5votes
1answer
2kviews
Convert bool to int and int to bool
I'm a noob. I wrote this code to convert bools to ints and ints to bools as a past-time but I would like to know whether to continue programming - this is the kind of thing I've been doing, no useful ...
4votes
1answer
228views
Fahrenheit <=> Celsius converter in Rust
It's one of the tasks suggested in the Rust Programming Language book by Steve Klabnik and Carol Nichols, and to a complete Rust newbie like me, figuring out converting scale from ...
6votes
1answer
221views
General bytes to number converter (c++)
I've written a bytes to number converter for cpp similar to the python int.from_bytes. It does not make any assumptions on: The endianness of the input buffer The ...
2votes
2answers
2kviews
Mapping pandas' Series to dataclasses
I've got something really simple this time where I'm mapping pandas' Series to dataclasses with a oneliner helper function (as ...
2votes
3answers
362views
length unit converter
I'm trying to make a imperial/metric length unit converter in Python. Here is my full code: ...