@@ -260,11 +260,21 module Redmine | |||||
260 | def scm_iconv(to, from, str) |
|
260 | def scm_iconv(to, from, str) | |
261 | return nil if str.nil? |
|
261 | return nil if str.nil? | |
262 | return str if to == from |
|
262 | return str if to == from | |
263 | begin |
|
263 | if str.respond_to?(:force_encoding) | |
264 | Iconv.conv(to, from, str) |
|
264 | str.force_encoding(from) | |
265 | rescue Iconv::Failure => err |
|
265 | begin | |
266 | logger.error("failed to convert from #{from} to #{to}. #{err}") |
|
266 | s = str.encode(to) | |
267 | nil |
|
267 | rescue Exception => e | |
|
268 | logger.error("failed to convert from #{from} to #{to}. #{err}") | |||
|
269 | nil | |||
|
270 | end | |||
|
271 | else | |||
|
272 | begin | |||
|
273 | Iconv.conv(to, from, str) | |||
|
274 | rescue Iconv::Failure => err | |||
|
275 | logger.error("failed to convert from #{from} to #{to}. #{err}") | |||
|
276 | nil | |||
|
277 | end | |||
268 | end |
|
278 | end | |
269 | end |
|
279 | end | |
270 |
|
280 |
General Comments 0
You need to be logged in to leave comments.
Login now