Open henrik-forsell opened 2 months ago
Currently the extension is using PROC JSON to dump the table content to JSON to be easily consumed by JS. It appears that PROC JSON can't handle the encoding well. Run below code will produce wrong characters into log.
filename out temp;
proc json nokeys out=out pretty; export work.myencoding; run;
data _null_; infile out; input; put _infile_; run;
I think we should take the OLE DB Provider (ADO) approach like EG.
As you guessed, there are odd chars in the log:
Writing down development details. I tried ADO approach with below code
$objFactory = New-Object -ComObject SASObjectManager.ObjectFactoryMulti2
$objServerDef = New-Object -ComObject SASObjectManager.ServerDef
$objServerDef.MachineDNSName = "localhost"
$objServerDef.Protocol = 0
# Class Identifier for SAS Workspace
$objServerDef.ClassIdentifier = "440196d4-90f0-11d0-9f41-00a024bb830c"
# create and connect to the SAS session
$objSAS = $objFactory.CreateObjectByServer(
"test",
$true,
$objServerDef, # built server definition
"",
""
)
# Add the new workspace object to the ObjectKeeper
$objOK = New-Object -ComObject SASObjectManager.ObjectKeeper
$objOK.AddObject(1, "WorkspaceObject", $objSAS)
# Open a connection to the workspace by using its UniqueIdentifier, which is generated automatically
$objConn = New-Object -ComObject ADODB.Connection
$objConn.Open("Provider=sas.iomprovider; Data Source=iom-id://"+$objSAS.UniqueIdentifier)
$objRecordSet = New-Object -ComObject ADODB.Recordset
$objRecordSet.ActiveConnection = $objConn
$objRecordSet.Properties.Item("SAS Formats").Value = "_ALL_"
$objRecordSet.Open("select * from sashelp.cars")
Write-Host $objRecordSet.Fields.Item(0).Value
$objRecordSet.Close()
It can print correct data. But the PowerShell process constantly crashes when closing the RecordSet.
If I remove the line
$objRecordSet.Properties.Item("SAS Formats").Value = "_ALL_"
It will not crash. But we do need to display formatted data.
I don't know how to solve this problem at the moment.
Not knowing anything about the code, but should the troubling row be before the open-statement and not after? If that is not the issue, would it help to test specific variables and not all?
Describe the bug Create a data set with that contains national characters, e.g. ÅÄÖ. Open the data set and it will not show those chars correctly.
Steps to reproduce *Create a data set with national chars; data work.myencoding; check_encoding="aa å, ae ä, oe ö"; run;
*Print values to the log, it will show it correctly; data null; set work.myencoding; put check_encoding; run;
*Print the data set to output, it will show it correctly; proc print data=work.myencoding; run;
Open the data set from the library and it will be showing the wrong characters.
Expected behavior The view table should show the national characters correctly.
Screenshots
Environment (please complete the following information): Client OS: Windows 11 Extension version: v1.10.1 SAS version: 9.4