void rename_revert(const char* src, char* dst)
{
- uint16_t dst_count = 0;
- size_t length = strlen(src);
- for (size_t i = 0; i < length; i++) {
- if (src[i] == '_') {
- dst[dst_count++] = SPACE;
- } else if (src[i] == 'a' && src[i + 1] == 'e') {
- i++;
- dst[dst_count++] = WIDE_CHAR_SHORT_PREFIX;
- dst[dst_count++] = WIDE_CHAR_SHORT_a;
- } else if (src[i] == 'A' && src[i + 1] == 'e') {
- i++;
- dst[dst_count++] = WIDE_CHAR_SHORT_PREFIX;
- dst[dst_count++] = WIDE_CHAR_SHORT_A;
- } else if (src[i] == 'o' && src[i + 1] == 'e') {
- i++;
- dst[dst_count++] = WIDE_CHAR_SHORT_PREFIX;
- dst[dst_count++] = WIDE_CHAR_SHORT_o;
- } else if (src[i] == 'O' && src[i + 1] == 'e') {
- i++;
- dst[dst_count++] = WIDE_CHAR_SHORT_PREFIX;
- dst[dst_count++] = WIDE_CHAR_SHORT_O;
- } else if (src[i] == 'u' && src[i + 1] == 'e') {
- i++;
- dst[dst_count++] = WIDE_CHAR_SHORT_PREFIX;
- dst[dst_count++] = WIDE_CHAR_SHORT_u;
- } else if (src[i] == 'U' && src[i + 1] == 'e') {
- i++;
- dst[dst_count++] = WIDE_CHAR_SHORT_PREFIX;
- dst[dst_count++] = WIDE_CHAR_SHORT_U;
- } else if (src[i] == 's' && src[i + 1] == 's') {
- i++;
- dst[dst_count++] = WIDE_CHAR_SHORT_PREFIX;
- dst[dst_count++] = WIDE_CHAR_SHORT_SS;
- } else {
- dst[dst_count++] = src[i];
- }
- }
+ size_t len = strlen(src) + 1;
+ char* out = malloc(len);
+ if (out == NULL)
+ return;
+
+ memcpy(out, src, len);
+
+ out = replace(&out, "_", " ");
+ out = replace(&out, "ae", "ä");
+ out = replace(&out, "Ae", "Ä");
+ out = replace(&out, "oe", "ö");
+ out = replace(&out, "Oe", "Ö");
+ out = replace(&out, "ue", "ü");
+ out = replace(&out, "Ue", "Ü");
+ out = replace(&out, "ss", "ß");
+
+ memcpy(dst, out, strlen(out) + 1);
+ free(out);
+ out = NULL;
}