Trapping errors within unpack?

Discussion in 'Ruby' started by Lloyd Zusman, Aug 29, 2004.

  1. Lloyd Zusman

    Lloyd Zusman Guest

    I'm trying to do a simple conversion between UTF-8 and 8-bit ascii.
    The key part of my program goes like this:

    ARGF.each {
    |line|
    puts line.unpack('U*').pack('c*')
    }

    This works fine unless the input contains an invalid UTF-8 character
    (which sometimes occurs). In that case, the 'unpack' method terminates
    at the offending character, and no more translation takes place.

    What I'd like to do is trap errors like that and put some sort of
    special character in the output (such as '?') for each invalid UTF-8
    character that is encountered, and then continue with the rest of the
    input. However, I don't know how to do that within 'unpack'.

    Can anyone suggest a solution?

    Thanks in advance.

    --
    Lloyd Zusman

    God bless you.
    Lloyd Zusman, Aug 29, 2004
    #1
    1. Advertising

  2. Lloyd Zusman

    Zach Dennis Guest

    cygwin c++ linking help

    Hi,

    This isn't directly pertaining to ruby under cygwin, because I can
    successfully compile ruby under cygwin. I am attempting to compile
    wxruby under cygwin and I haven't had that much luck. All of my files
    compile but when the object files are linked together they always error
    out with a bunch of "undefined resource" errors. I was wondering if
    anyone with more experience in this area could point me in a direction ,
    like my library file isn't being found, i am missing a library file, I
    should check my library file for certain method signatures, etc...

    here is some of the output i get...any pointers would be of great help.
    Thanks,

    Zach

    c++ -shared -s -L/usr/local/lib /usr/local/lib/libwxmsw242d.a -ljpeg
    -ltiff -lz -lrpcrt4 -loleaut32 -lole32 -luuid -lwinspool -lwinmm
    -lshell32 -lcomctl32 -lctl3d32 -ladvapi32 -lwsock32 -lkernel32 -luser32
    -lgdi32 -lcomdlg32 -Wl,--enable-auto-import,--export-all
    -L"/usr/local/lib" -L/usr/src/wxWindows-2.4.2/libs -o wxruby.so
    htmlprocessor.o htmlwindow.o htmleasyprinting.o wx.o app.o bitmap.o
    button.o calendar.o checkbox.o choice.o colour.o colourdata.o
    colourdialog.o combobox.o const.o date.o dialog.o dirdialog.o event.o
    evthandler.o filedialog.o font.o fontdata.o fontdialog.o frame.o gauge.o
    layout.o listbox.o menu.o menubar.o messagedialog.o point.o radio.o
    rect.o size.o sizer.o slider.o spin.o statictext.o textctrl.o timer.o
    validator.o window.o icon.o artprovider.o log.o listctrl.o list.o
    panel.o scrolledwindow.o dc.o brush.o pen.o caret.o statusbar.o
    ownerdrawn.o config.o region.o cursor.o notebook.o tooltip.o mask.o
    socket.o url.o stream.o toolbar.o image.o palette.o treectrl.o
    classinfo.o splitterwindow.o methods.o staticbitmap.o control.o grid.o
    menuitem.o textattr.o dataformat.o togglebutton.o dropsource.o
    droptarget.o textdroptarget.o filedroptarget.o filedataobject.o
    textdataobject.o dataobject.o dataobjectsimple.o dynamiccast.o
    mdiparentframe.o mdiclientwindow.o mdichildframe.o -lruby -lcrypt

    htmlprocessor.o(.text+0x3ca): In function
    `_ZN15WxHtmlProcessor7ProcessEiPmm':
    /usr/src/wxWindows-2.4.2/include/wx/string.h:249: undefined reference to
    `_wxEmptyString'
    htmlprocessor.o(.text+0x3f8): In function
    `_ZN15WxHtmlProcessor7ProcessEiPmm':
    /usr/src/wxruby-0.5-src/src/htmlprocessor.cpp:82: undefined reference to
    `wxString::eek:perator=(char const*)'
    htmlprocessor.o(.text+0x6f4): In function
    `_ZNK21wxHtmlProcessorHelper7ProcessERK8wxString':
    /usr/src/wxWindows-2.4.2/include/wx/string.h:311: undefined reference to
    `wxString::InitWith(char const*, unsigned, unsigned)'
    htmlprocessor.o(.rdata$_ZTV21wxHtmlProcessorHelper+0x14): In function
    `_ZNK15wxHtmlProcessor11GetPriorityEv':
    /usr/src/wxWindows-2.4.2/include/wx/html/htmlproc.h: undefined reference
    to `wxObject::CreateRefData() const'
    htmlprocessor.o(.rdata$_ZTV21wxHtmlProcessorHelper+0x18):/usr/src/wxWindows-2.4.2/include/wx/html/htmlproc.h:
    undefined reference to `wxObject::CloneRefData(wxObjectRefData const*)
    const'
    htmlprocessor.o(.text$_ZNK15wxHtmlProcessor12GetClassInfoEv+0x4):/usr/src/wxWindows-2.4.2/include/wx/html/htmlproc.h:
    undefined reference to `wxHtmlProcessor::sm_classwxHtmlProcessor'
    htmlprocessor.o(.text$_ZN21wxHtmlProcessorHelperD1Ev+0xb):/usr/src/wxWindows-2.4.2/include/wx/html/htmlproc.h:
    undefined reference to `vtable for wxObject'
    htmlprocessor.o(.text$_ZN21wxHtmlProcessorHelperD1Ev+0x13):/usr/src/wxWindows-2.4.2/include/wx/html/htmlproc.h:
    undefined reference to `wxObject::UnRef()'
    htmlprocessor.o(.text$_ZN21wxHtmlProcessorHelperD0Ev+0xe):/usr/src/wxWindows-2.4.2/include/wx/html/htmlproc.h:
    undefined reference to `vtable for wxObject'
    htmlprocessor.o(.text$_ZN21wxHtmlProcessorHelperD0Ev+0x16):/usr/src/wxWindows-2.4.2/include/wx/html/htmlproc.h:
    undefined reference to `wxObject::UnRef()'
    htmlwindow.o(.text+0x697): In function
    `_ZN12WxHtmlWindow12constructor0EiPmm':
    /usr/src/wxruby-0.5-src/src/htmlwindow.cpp:110: undefined reference to
    `_wxDefaultPosition'
    htmlwindow.o(.text+0x6a6):/usr/src/wxruby-0.5-src/src/htmlwindow.cpp:113:
    undefined reference to `_wxDefaultSize'
    htmlwindow.o(.text+0x710): In function
    `_ZN12WxHtmlWindow12constructor0EiPmm':
    /usr/src/wxWindows-2.4.2/include/wx/string.h:311: undefined reference to
    `wxString::InitWith(char const*, unsigned, unsigned)'
    Zach Dennis, Aug 29, 2004
    #2
    1. Advertising

  3. Lloyd Zusman

    Guest

    Re: cygwin c++ linking help

    Hi,

    At Sun, 29 Aug 2004 11:57:41 +0900,
    Zach Dennis wrote in [ruby-talk:110861]:
    > This isn't directly pertaining to ruby under cygwin, because I can
    > successfully compile ruby under cygwin. I am attempting to compile
    > wxruby under cygwin and I haven't had that much luck. All of my files
    > compile but when the object files are linked together they always error
    > out with a bunch of "undefined resource" errors. I was wondering if
    > anyone with more experience in this area could point me in a direction ,
    > like my library file isn't being found, i am missing a library file, I
    > should check my library file for certain method signatures, etc...


    It is a FAQ of ld.
    <http://www.delorie.com/djgpp/v2faq/faq8_10.html>

    The order of -l options is important. Try moving them after
    the object files.

    --
    Nobu Nakada
    , Aug 30, 2004
    #3
  4. Lloyd Zusman

    Zach Dennis Guest

    Re: cygwin c++ linking help

    wrote:

    >Hi,
    >
    >At Sun, 29 Aug 2004 11:57:41 +0900,
    >Zach Dennis wrote in [ruby-talk:110861]:
    >
    >
    >>This isn't directly pertaining to ruby under cygwin, because I can
    >>successfully compile ruby under cygwin. I am attempting to compile
    >>wxruby under cygwin and I haven't had that much luck. All of my files
    >>compile but when the object files are linked together they always error
    >>out with a bunch of "undefined resource" errors. I was wondering if
    >>anyone with more experience in this area could point me in a direction ,
    >>like my library file isn't being found, i am missing a library file, I
    >>should check my library file for certain method signatures, etc...
    >>
    >>

    >
    >It is a FAQ of ld.
    ><http://www.delorie.com/djgpp/v2faq/faq8_10.html>
    >
    >The order of -l options is important. Try moving them after
    >the object files.
    >
    >
    >

    Thank you Nobu, that solved the linking issue i was getting.

    Zach
    Zach Dennis, Aug 30, 2004
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?QmlsbA==?=

    Trapping 'compile' errors when aspx page is rendered.

    =?Utf-8?B?QmlsbA==?=, Mar 29, 2005, in forum: ASP .Net
    Replies:
    4
    Views:
    506
    =?Utf-8?B?QmlsbA==?=
    Mar 29, 2005
  2. Aaron Fude

    Trapping JNI errors

    Aaron Fude, Jun 1, 2004, in forum: Java
    Replies:
    4
    Views:
    1,488
    Gordon Beaton
    Jun 2, 2004
  3. Avi Kak
    Replies:
    6
    Views:
    310
    Duncan Booth
    Feb 13, 2006
  4. Eitan

    Trapping errors in ASP

    Eitan, Jan 12, 2005, in forum: ASP General
    Replies:
    6
    Views:
    125
    Bob Barrows [MVP]
    Jan 13, 2005
  5. Eitan
    Replies:
    3
    Views:
    128
    Bob Barrows [MVP]
    Jan 12, 2005
Loading...

Share This Page