1. Parvejali Chodhary
  2. PowerBuilder
  3. Monday, 9 September 2024 05:10 AM UTC

Hi,

I have nvarchar column which i use to save Arabic strings. When i save text from datawindow it saves as '?????? ???? ??????? 125?*15'.

But from backend its saves fine and works.

Any solutions?

 

Tool Using PowerBuilder 2022 R2, MS SQL server 2014

 

Accepted Answer
Sivaprakash BKR Accepted Answer Pending Moderation
  1. Monday, 9 September 2024 05:34 AM UTC
  2. PowerBuilder
  3. # Permalink

If I understand correctly, you want to save arabic text into a SQL Server Database field.  Am I right?  Then write the below code into SQLPreview Event of that particular datawindow

n_dwr_string	lnv_string

Choose case sqltype
	Case PreviewInsert!
		sqlsyntax = lnv_string.of_globalreplace(sqlsyntax,"( '", "( N'")
		sqlsyntax = lnv_string.of_globalreplace(sqlsyntax ,", '", ",N'")
		this.setsqlpreview(sqlsyntax)
		
	Case PreviewUpdate!, PreviewDelete!
		sqlsyntax = lnv_string.of_globalreplace(sqlsyntax ,"= '","= N'")
		this.setsqlpreview(sqlsyntax)
End Choose

It will prefix the character 'N' before inserting the data into the column.

HTH

Happiness Always
BKR Sivaprakash

 

Comment
  1. Parvejali Chodhary
  2. Monday, 9 September 2024 05:59 AM UTC


Thank you for replying.



Yes I need to save and update Arabic text to the database.



From where i can get this n_dwr_string.
  1. Helpful
  1. Sivaprakash BKR
  2. Monday, 9 September 2024 06:17 AM UTC
//////////////////////////////////////////////////////////////////////////////

//

// Function: of_GlobalReplace

//

// Access: public

//

// Arguments:

// as_Source The string being searched.

// as_Old The old string being replaced.

// as_New The new string.

// ab_IgnoreCase A boolean stating to ignore case sensitivity.

//

// Returns: string

// as_Source with all occurrences of as_Old replaced with as_New.

// If any argument's value is NULL, function returns NULL.

//

// Description: Replace all occurrences of one string inside another with

// a new string.

//

//////////////////////////////////////////////////////////////////////////////

//

// Revision History

//

// Version

// 5.0 Initial version

//

//////////////////////////////////////////////////////////////////////////////

//

// Copyright © 1996-1997 Sybase, Inc. and its subsidiaries. All rights reserved.

// Any distribution of the PowerBuilder Foundation Classes ( PFC )

// source code by other than Sybase, Inc. and its subsidiaries is prohibited.

//

//////////////////////////////////////////////////////////////////////////////



Long ll_Start, ll_OldLen, ll_NewLen

String ls_Source



//Check parameters

If IsNull ( as_source ) or IsNull ( as_old ) or IsNull ( as_new ) or IsNull ( ab_ignorecase ) Then

string ls_null

SetNull ( ls_null )

Return ls_null

End If



//Get the string lenghts

ll_OldLen = Len ( as_Old )

ll_NewLen = Len ( as_New )



//Should function respect case.

If ab_ignorecase Then

as_old = Lower ( as_old )

ls_source = Lower ( as_source )

Else

ls_source = as_source

End If



//Search for the first occurrence of as_Old

ll_Start = Pos ( ls_Source, as_Old )



Do While ll_Start > 0

// replace as_Old with as_New

as_Source = Replace ( as_Source, ll_Start, ll_OldLen, as_New )



//Should function respect case.

If ab_ignorecase Then

ls_source = Lower ( as_source )

Else

ls_source = as_source

End If



// find the next occurrence of as_Old

ll_Start = Pos ( ls_Source, as_Old, ( ll_Start + ll_NewLen ) )

Loop



Return as_Source





You can use the above function to replace values.

  1. Helpful
  1. Parvejali Chodhary
  2. Monday, 9 September 2024 06:39 AM UTC
Thank you very much.
  1. Helpful
There are no comments made yet.
Parvejali Chodhary Accepted Answer Pending Moderation
  1. Monday, 9 September 2024 05:58 AM UTC
  2. PowerBuilder
  3. # 1

Thank you for replying.

Yes i need to save and update Aarabic text to database.

From where i can get this n_dwr_string.

Comment
There are no comments made yet.
John Fauss Accepted Answer Pending Moderation
  1. Monday, 9 September 2024 05:26 AM UTC
  2. PowerBuilder
  3. # 2

What DataWindow Control method are you using to save the Arabic data as text?

The SaveAs and SaveAsFormattedText methods support an optional encoding argument that is use to specify the desired encoding. I believe that you must use Unicode16LE encoding to faithfully save the Arabic text.

Consult PB Help for these methods for details.

Best regards, John

Comment
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.
We use cookies which are necessary for the proper functioning of our websites. We also use cookies to analyze our traffic, improve your experience and provide social media features. If you continue to use this site, you consent to our use of cookies.