195 | | int cw = 1; |
196 | | gboolean read_res = TRUE; |
197 | | |
198 | | ch = mcview_get_utf (view, from, &cw, &read_res); |
199 | | if (!read_res) |
200 | | break; |
201 | | /* char width is greater 0 bytes */ |
202 | | if (cw != 0) |
203 | | { |
204 | | int cnt; |
205 | | char corr_buf[UTF8_CHAR_LEN + 1]; |
206 | | struct hexedit_change_node *corr = curr; |
207 | | int res; |
208 | | |
209 | | res = g_unichar_to_utf8 (ch, (char *) corr_buf); |
210 | | |
211 | | for (cnt = 0; cnt < cw; cnt++) |
212 | | { |
213 | | if (curr != NULL && from + cnt == curr->offset) |
214 | | { |
215 | | /* replace only changed bytes in array of multibyte char */ |
216 | | corr_buf[cnt] = curr->value; |
217 | | curr = curr->next; |
218 | | } |
219 | | } |
220 | | corr_buf[res] = '\0'; |
221 | | /* Determine the state of the current multibyte char */ |
222 | | ch = utf8_to_int ((char *) corr_buf, &cw, &read_res); |
223 | | curr = corr; |
| 195 | int res; |
| 196 | int j; |
| 197 | struct hexedit_change_node *corr = curr; |
| 198 | gchar utf8buf[UTF8_CHAR_LEN + 1]; |
| 199 | |
| 200 | for (j = 0; j < UTF8_CHAR_LEN; j++) { |
| 201 | if (mcview_get_byte (view, from + j, &res)) |
| 202 | utf8buf[j] = res; |
| 203 | else |
| 204 | { |
| 205 | utf8buf[j] = '\0'; |
| 206 | break; |
| 207 | } |
| 208 | if (curr != NULL && from + j == curr->offset) |
| 209 | utf8buf[j] = curr->value; |
| 210 | if (curr != NULL && from + j >= curr->offset) |
| 211 | curr = curr->next; |