Skip to content

Commit

Permalink
Support mixed UTF-16 content for ADP
Browse files Browse the repository at this point in the history
Components like forms and reports that are exported from an ADP project do not use UCS BOM markers, but may contain UTF-16 unicode characters. (Such as unicode characters in form controls.) This change uses `TristateMixed` when reading files exported from ADP projects, which allows us to properly convert these to UTF-8 for representation in Version Control.
  • Loading branch information
joyfullservice committed Jul 13, 2020
1 parent 2e8762f commit dadf500
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 8 deletions.
4 changes: 2 additions & 2 deletions Version Control.accda.src/dbs-properties.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"Info": {
"Class": "clsDbProperty",
"Description": "Database Properties (DAO)",
"VCS Version": "3.1.51"
"VCS Version": "3.1.52"
},
"Items": {
"AccessVersion": {
Expand Down Expand Up @@ -42,7 +42,7 @@
"Type": 10
},
"AppVersion": {
"Value": "3.1.51",
"Value": "3.1.52",
"Type": 10
},
"Auto Compact": {
Expand Down
22 changes: 18 additions & 4 deletions Version Control.accda.src/modules/modFileAccess.bas
Original file line number Diff line number Diff line change
Expand Up @@ -137,17 +137,31 @@ Public Sub ConvertUcs2Utf8(strSourceFile As String, strDestinationFile As String
Dim strText As String
Dim utf8Bytes() As Byte
Dim fnum As Integer
Dim blnIsAdp As Boolean
Dim intTristate As Tristate

' Make sure the path exists before we write a file.
' Make sure the path exists and remove any existing file.
VerifyPath FSO.GetParentFolderName(strDestinationFile)

If FSO.FileExists(strDestinationFile) Then Kill strDestinationFile

' ADP Projects do not use the UCS BOM, but may contain mixed UTF-16 content
' representing unicode characters.
blnIsAdp = (CurrentProject.ProjectType = acADP)

' Check the first couple characters in the file for a UCS BOM.
If FileIsUCS2Format(strSourceFile) Then
If FileIsUCS2Format(strSourceFile) Or blnIsAdp Then

' Determine format
If blnIsAdp Then
' Possible mixed UTF-16 content
intTristate = TristateMixed
Else
' Fully encoded as UTF-16
intTristate = TristateTrue
End If

' Read file contents and delete (temp) source file
With FSO.OpenTextFile(strSourceFile, ForReading, False, TristateTrue)
With FSO.OpenTextFile(strSourceFile, ForReading, False, intTristate)
strText = .ReadAll
.Close
End With
Expand Down
4 changes: 2 additions & 2 deletions Version Control.accda.src/vbe-project.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
"Info": {
"Class": "clsDbVbeProject",
"Description": "VBE Project",
"VCS Version": "3.1.51"
"VCS Version": "3.1.52"
},
"Items": {
"Name": "MSAccessVCS",
"Description": "Version 3.1.51 deployed on 7/2/2020",
"Description": "Version 3.1.52 deployed on 7/13/2020",
"FileName": "rel:Version Control.accda",
"HelpFile": "",
"HelpContextId": 0,
Expand Down

0 comments on commit dadf500

Please sign in to comment.