Strange characters on the field

I did the migration of customer data from cobol files (.dat) to MySql.
The conversion went fine but now when I consult the data on the screen appear strange characters in special characters (accents, etc).
I'm using Windows with WPF.
I want send a few prints of the database and what appears on the screen but i don't know how.

What is wrong? Will need to change some codepage?

  • Can you please provide some more detail?

    How is the column defined in the database?

    What is the type of the host variable used to hold the data?

    What is the content of the data within the column?

    How are you displaying this data to the screen?

    Thanks

  • Hello.

    Thanks for the reply.

    In the database the column is set to type CHAR.

    In the aplication i use pic x(50).

    For example i have in database the name of the client like that:

    JOSÉ ANTÓNIO DA COSTA GONÇALVES

    In the aplication i have:

    JOS� ANT�NIO DA COSTA GON�ALVES    

    The problem happens both in the list view as a normal dilsplay for a text field.

    Best regards

  • If your file is codepage OEM, try to convert it to CHAR.

    01  status-code           pic x(2) comp-x.

    01  redefines status-code.

         02 fs-byte-1          pic x(1).

         02 fs-byte-2          pic x(1) comp-x.

    01  sizevar                 pic x(4) comp-x.

    call "PC_WIN_OEM_TO_CHAR" using InputName OutputName                                                                    

                                                              by value sizevar sizevar

                                                              returning status-code            

    end-call

  • I tried to do as is in the case and gave the following error:

    ArgumentException was unhandled.

    In Portuguese:

    O deslocamento e o comprimento estavam fora dos limites para a matriz ou a contagem é superior ao número de elementos desde o índice até ao fim da colecção de origem.

    In English (with translator):

    The offset and length were out of bounds for the array or count is greater than the number of elements from index to the end of the source collection.

    The input and the output file aro both PIC X(50):

    Thanks

  • This error is occurring in the query or when converting DAT to MySQL? Try using the function "PC_WIN_OEM_TO_CHAR"  while converting the base.

    Try also remove null characters before conversion

    1 InputName pic x(50).

    1 numfield  binary-long.

    1 myString string.

    *> Remove null characters from the DAT field.

    perform varying numfield from length of InputName by -1 until

         InputName(numField : 1) not = space or numField = 1

    end-perform  

    set myString to InputName

    display myString.

  • This error occurs when i show the data in the listview or in a field (in the query).

    In the MySql the data is ok.

    If you explain me haw, i send a print for the data in MySql and in the listview/field.

    I gonna try use the "PC_WIN_OEM_TO_CHAR" when i convert the .DAT to MySql.

    The solution "Remove null characters from the DAT field" i think is not the best way because the result of the name of the client is not the correct.

  • Ok. I have an application to fill out a datagridview with native file data (OEM) and do the conversion before showing the grid and works perfectly. I think using PC_WIN_OEM_TO_CHAR while converting .DAT to MySQL, this problem will be solved.

  • I've done the experience of using "PC_WIN_OEM_TO_CHAR" on data conversion. Dat file to MySql and gives the same error

    System.ArgumentException was unhandled

     HResult=-2147024809

     Message=O deslocamento e o comprimento estavam fora dos limites para a matriz ou a contagem é superior ao número de elementos desde o índice até ao fim da colecção de origem.

     Source=mscorlib

     ParamName=""

     StackTrace:

          em System.Buffer.BlockCopy(Array src, Int32 srcOffset, Array dst, Int32 dstOffset, Int32 count)

          em MicroFocus.COBOL.Program.Reference.GetBytes(Int32 offset, Int32 length)

          em MicroFocus.COBOL.Program.Reference.GetBytes(Int32 length)

          em MicroFocus.COBOL.Runtime.CharAPI.PC_WIN_OEM_TO_CHAR(Reference source, Reference target, UInt32 slen, UInt32 tlen)

          em WPFApplication1.Simdados._MF_PERFORM_58_18() em C:\Users\user\Documents\Visual Studio 2013\Projects\WPFApplication1\WPFApplication1\Simdados.cbl:line 573

          em WPFApplication1.Simdados._MF_PERFORM_58_13() em C:\Users\user\Documents\Visual Studio 2013\Projects\WPFApplication1\WPFApplication1\Simdados.cbl:line 299

          em WPFApplication1.Simdados.Simdados() em C:\Users\user\Documents\Visual Studio 2013\Projects\WPFApplication1\WPFApplication1\Simdados.cbl:line 154

          em WPFApplication1.Menus.bdCriacao_Click(Object sender, RoutedEventArgs e) em C:\Users\user\Documents\Visual Studio 2013\Projects\WPFApplication1\WPFApplication1\Menus.xaml.cbl:line 72

          em System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)

          em System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)

          em System.Windows.Controls.MenuItem.InvokeClickAfterRender(Object arg)

          em System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)

          em MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)

          em System.Windows.Threading.DispatcherOperation.InvokeImpl()

          em System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)

          em System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)

          em System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)

          em System.Windows.Threading.DispatcherOperation.Invoke()

          em System.Windows.Threading.Dispatcher.ProcessQueue()

          em System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)

          em MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)

          em MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)

          em System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)

          em MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)

          em System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)

          em MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)

          em MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)

          em System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)

          em System.Windows.Application.RunInternal(Window window)

          em System.Windows.Application.Run()

          em WPFApplication1.App.Main() em C:\Users\user\Documents\Visual Studio 2013\Projects\WPFApplication1\WPFApplication1\obj\Debug\App.g.cbl:line 24

     InnerException:

  • Try setting the compiler directive runtimeencoding(ansi) on in the COBOL tab of the project properties. This should tell it to treat PIC X data using the ANSI codeset.

    You could also try using CBL_STRING_CONVERT to convert between ansi and Unicode and then use the converted string in your Textbox.

    Example

    call "CBL_STRING_CONVERT" using by reference test-record

                                   by value 10

                                   by value 3

                                   by reference mypicn

                                   by reference 20

                                   by value 1

                                   by value 0

                                   by reference reserved

                                   returning status-code.

    set txtBox1::Text to mypicn