aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/charConv.c22
-rw-r--r--src/path.c4
-rw-r--r--src/tag.c2
-rw-r--r--src/utf8.c22
-rw-r--r--src/utf8.h8
5 files changed, 27 insertions, 31 deletions
diff --git a/src/charConv.c b/src/charConv.c
index 402683e18..85eba7e88 100644
--- a/src/charConv.c
+++ b/src/charConv.c
@@ -34,10 +34,10 @@ char * char_conv_from = NULL;
mpd_sint8 char_conv_same = 0;
mpd_sint8 char_conv_use_iconv = 0;
-/* 1 is to use asciiToUtf8
- 0 is not to use ascii/utf8 converter
- -1 is to use utf8ToAscii*/
-mpd_sint8 char_conv_asciiToUtf8 = 0;
+/* 1 is to use latin1ToUtf8
+ 0 is not to use latin1/utf8 converter
+ -1 is to use utf8ToLatin1*/
+mpd_sint8 char_conv_latin1ToUtf8 = 0;
#define BUFFER_SIZE 1024
@@ -58,13 +58,13 @@ int setCharSetConversion(char * to, char * from) {
}
if(strcmp(to,"UTF-8")==0 && strcmp(from,"ISO-8859-1")==0) {
- char_conv_asciiToUtf8 = 1;
+ char_conv_latin1ToUtf8 = 1;
}
else if(strcmp(to,"ISO-8859-1")==0 && strcmp(from,"UTF-8")==0) {
- char_conv_asciiToUtf8 = -1;
+ char_conv_latin1ToUtf8 = -1;
}
- if(char_conv_asciiToUtf8!=0) {
+ if(char_conv_latin1ToUtf8!=0) {
char_conv_to = strdup(to);
char_conv_from = strdup(from);
return 0;
@@ -121,12 +121,12 @@ char * convStrDup(char * string) {
}
#endif
- switch(char_conv_asciiToUtf8) {
+ switch(char_conv_latin1ToUtf8) {
case 1:
- return asciiStrToUtf8Dup(string);
+ return latin1StrToUtf8Dup(string);
break;
case -1:
- return utf8StrToAsciiDup(string);
+ return utf8StrToLatin1Dup(string);
break;
}
@@ -143,7 +143,7 @@ void closeCharSetConversion() {
char_conv_to = NULL;
char_conv_from = NULL;
char_conv_same = 0;
- char_conv_asciiToUtf8 = 0;
+ char_conv_latin1ToUtf8 = 0;
char_conv_use_iconv = 0;
}
}
diff --git a/src/path.c b/src/path.c
index 8f4cb6911..e9031100d 100644
--- a/src/path.c
+++ b/src/path.c
@@ -20,7 +20,6 @@
#include "log.h"
#include "charConv.h"
#include "conf.h"
-#include "utf8.h"
#include <stdlib.h>
#include <string.h>
@@ -59,9 +58,6 @@ char * fsCharsetToUtf8(char * str) {
free(ret);
ret = NULL;
}
- /*if(!ret) ret = asciiStrToUtf8Dup(str);*/
-
- /* if all else fails, just strdup */
return ret;
}
diff --git a/src/tag.c b/src/tag.c
index 63a7719db..23128ae16 100644
--- a/src/tag.c
+++ b/src/tag.c
@@ -63,7 +63,7 @@ void printMpdTag(FILE * fp, MpdTag * tag) {
if(str && !validUtf8String(str)) { \
char * temp; \
DEBUG("not valid utf8 in tag: %s\n",str); \
- temp = asciiStrToUtf8Dup(str); \
+ temp = latin1StrToUtf8Dup(str); \
free(str); \
str = temp; \
} \
diff --git a/src/utf8.c b/src/utf8.c
index 4b8814a80..09c290291 100644
--- a/src/utf8.c
+++ b/src/utf8.c
@@ -4,7 +4,7 @@
#include <string.h>
#include <stdlib.h>
-unsigned char * asciiToUtf8(unsigned char c) {
+unsigned char * latin1ToUtf8(unsigned char c) {
static unsigned char utf8[3];
memset(utf8,0,3);
@@ -22,9 +22,9 @@ unsigned char * asciiToUtf8(unsigned char c) {
return utf8;
}
-unsigned char * asciiStrToUtf8Dup(unsigned char * ascii) {
- /* utf8 should have at most two char's per ascii char */
- int len = strlen(ascii)*2+1;
+unsigned char * latin1StrToUtf8Dup(unsigned char * latin1) {
+ /* utf8 should have at most two char's per latin1 char */
+ int len = strlen(latin1)*2+1;
unsigned char * ret = malloc(len);
unsigned char * cp = ret;
unsigned char * utf8;
@@ -33,19 +33,19 @@ unsigned char * asciiStrToUtf8Dup(unsigned char * ascii) {
len = 0;
- while(*ascii) {
- utf8 = asciiToUtf8(*ascii);
+ while(*latin1) {
+ utf8 = latin1ToUtf8(*latin1);
while(*utf8) {
*(cp++) = *(utf8++);
len++;
}
- ascii++;
+ latin1++;
}
return realloc(ret,len+1);
}
-unsigned char utf8ToAscii(unsigned char * utf8) {
+unsigned char utf8ToLatin1(unsigned char * utf8) {
unsigned char c = 0;
if(utf8[0]<128) return utf8[0];
@@ -86,8 +86,8 @@ int validUtf8String(unsigned char * string) {
return 1;
}
-unsigned char * utf8StrToAsciiDup(unsigned char * utf8) {
- /* utf8 should have at most two char's per ascii char */
+unsigned char * utf8StrToLatin1Dup(unsigned char * utf8) {
+ /* utf8 should have at most two char's per latin1 char */
int len = strlen(utf8)+1;
unsigned char * ret = malloc(len);
unsigned char * cp = ret;
@@ -103,7 +103,7 @@ unsigned char * utf8StrToAsciiDup(unsigned char * utf8) {
free(ret);
return NULL;
}
- *(cp++) = utf8ToAscii(utf8);
+ *(cp++) = utf8ToLatin1(utf8);
utf8+= count;
len++;
}
diff --git a/src/utf8.h b/src/utf8.h
index bf8f1a9c9..761c676e5 100644
--- a/src/utf8.h
+++ b/src/utf8.h
@@ -1,13 +1,13 @@
#ifndef UTF_8_H
#define UTF_8_H
-unsigned char * asciiToUtf8(unsigned char c);
+unsigned char * latin1ToUtf8(unsigned char c);
-unsigned char * asciiStrToUtf8Dup(unsigned char * ascii);
+unsigned char * latin1StrToUtf8Dup(unsigned char * latin1);
-unsigned char * utf8StrToAsciiDup(unsigned char * utf8);
+unsigned char * utf8StrToLatin1Dup(unsigned char * utf8);
-unsigned char utf8ToAscii(unsigned char * utf8);
+unsigned char utf8ToLatin1(unsigned char * utf8);
int validateUtf8Char(unsigned char * utf8Char);