hi I use song_title to creat a file named by song_title.I have many song titles to create many files.but unfortunately,some of song titles contain special characters,such as [ ,which leads the following error: ##### Errno::EINVAL in Lyric spiderController#scrap_one_category Invalid argument - e:/rails/lyric/public/song/e/Energy/ [ar:Energy.lrc ##### I use the following codes to create and write to files: ##### File.open(singer_dir+"/"+UTF8_TO_GBK.iconv(song_title)+".lrc",''w'')do |f| f.write(lyric_initial_data) end ##### It is impossible to drop those special characters individually,and they are valid file names on my windows system when i manually create the file using them. I have used the CGI escape methods,but the resulted filename was not what i want. how to keep those characters for file name,and prevent the error happens? -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
hi can you help me? thank you! -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
hi is there any method to do it? thank you! -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
I don''t have any direct experience with this, but perhaps you could
begin isolating the problem by trying to directly pass a hard-coded
string as in
File.open("this_is_the_title.lrc","w"),
sidestepping the filename creation process.
On Sep 24, 1:40 pm, Guo Yangguang
<li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org>
wrote:> hi
> I use song_title to creat a file named by song_title.I have many song
> titles to create many files.but unfortunately,some of song titles
> contain special characters,such as [ ,which leads the following error:
> #####
> Errno::EINVAL in Lyric spiderController#scrap_one_category
> Invalid argument - e:/rails/lyric/public/song/e/Energy/
> [ar:Energy.lrc
> #####
> I use the following codes to create and write to files:
> #####
>
File.open(singer_dir+"/"+UTF8_TO_GBK.iconv(song_title)+".lrc",''w'')do
> |f|
>
> f.write(lyric_initial_data)
>
> end
> #####
>
> It is impossible to drop those special characters individually,and they
> are valid file names on my windows system when i manually create the
> file using them.
> I have used the CGI escape methods,but the resulted filename was not
> what i want.
>
> how to keep those characters for file name,and prevent the error
> happens?
> --
> Posted viahttp://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.
Phillip wrote:> I don''t have any direct experience with this, but perhaps you could > begin isolating the problem by trying to directly pass a hard-coded > string as in > File.open("this_is_the_title.lrc","w"), > sidestepping the filename creation process.Thank you,phillip.I am driven mad by those characters and encoding. -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Maybe Matching Threads
- Passing a variable between methods
- formula for degrees of freedom for nonlinear mixed model in nlme
- How to test significant differences for non-linear relationships for two locations
- winbind with ADS error
- SSweibull() : problems with step factor and singular gradient