J'essaye d'écrire une fonction qui remplace la caractères accentués dans un tableau de char, mais je m'emmêle les pinceaux avec les pointeurs... Un peu d'aide ? ? ?
Voici la fonction
void LookForAccents (char& Text, int TextLength) {
for (byte i = 0; i < TextLength; i++) {
if (*(Text+i) > 127) {
switch (*(Text+i)) {
case 128:
case 135:
*(Text+i) = 'c';
break;
case 129:
case 150 ... 151:
case 163:
*(Text+i) = 'u';
break;
default:
break;
}
}
}
}
Je l'ai simplifiée ici mais vous voyez le principe...
Un exemple d'appel :
LookForAccents (current_weather_description, strlen(current_weather_description));
Et les erreurs de compilation :
Arduino : 1.8.2 (Windows 10), Carte : "LOLIN D32, Default, 80MHz, 921600, None"
In file included from C:\Users\Chuwi\Documents\Arduino\_METEO\Meteo_ESP32_DeepSleep_epaper\Meteo_ESP32_DeepSleep_epaper.ino:2:0:
sketch\Weather.h: In function 'void LookForAccents(char&, int)':
Weather.h:6: error: invalid type argument of unary '*' (have 'int')
if (*(Text+i) > 127) {
^
Weather.h:7: error: invalid type argument of unary '*' (have 'int')
switch (*(Text+i)) {
^
Weather.h:10: error: invalid type argument of unary '*' (have 'int')
*(Text+i) = 'c';
^
Weather.h:15: error: invalid type argument of unary '*' (have 'int')
*(Text+i) = 'u';
^
In file included from C:\Users\Chuwi\Documents\Arduino\_METEO\Meteo_ESP32_DeepSleep_epaper\Meteo_ESP32_DeepSleep_epaper.ino:2:0:
sketch\Weather.h: In function 'void GetCurrentMeteo()':
Weather.h:129: error: invalid conversion from 'char*' to 'char' [-fpermissive]
LookForAccents (current_weather_description, strlen(current_weather_description));
^
In file included from C:\Users\Chuwi\Documents\Arduino\_METEO\Meteo_ESP32_DeepSleep_epaper\Meteo_ESP32_DeepSleep_epaper.ino:2:0:
sketch\Weather.h:4:6: note: initializing argument 1 of 'void LookForAccents(char&, int)'
void LookForAccents (char& Text, int TextLength) {
^
In file included from C:\Users\Chuwi\Documents\Arduino\_METEO\Meteo_ESP32_DeepSleep_epaper\Meteo_ESP32_DeepSleep_epaper.ino:2:0:
Weather.h:129: error: cannot bind rvalue '(char)((int)(& current_weather_description))' to 'char&'
LookForAccents (current_weather_description, strlen(current_weather_description));
^
In file included from C:\Users\Chuwi\Documents\Arduino\_METEO\Meteo_ESP32_DeepSleep_epaper\Meteo_ESP32_DeepSleep_epaper.ino:2:0:
sketch\Weather.h:4:6: note: initializing argument 1 of 'void LookForAccents(char&, int)'
void LookForAccents (char& Text, int TextLength) {
^
In file included from C:\Users\Chuwi\Documents\Arduino\_METEO\Meteo_ESP32_DeepSleep_epaper\Meteo_ESP32_DeepSleep_epaper.ino:2:0:
Weather.h:225: error: cannot bind rvalue '(char)((int)(& daily_weather_description[i]))' to 'char&'
LookForAccents (daily_weather_description[i], strlen(daily_weather_description[i]));
^
exit status 1
invalid type argument of unary '*' (have 'int')
Je pense que tout est là
Weather.h:129: error: cannot bind rvalue '(char)((int)(& current_weather_description))' to 'char&'
mais je ne comprends pas, ayant beaucoup de mal avec les pointeurs...