summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--basic/qa/basic_coverage/test_instr_method.vb17
-rw-r--r--basic/qa/vba_tests/instr.vb3
-rw-r--r--basic/source/runtime/methods.cxx9
3 files changed, 21 insertions, 8 deletions
diff --git a/basic/qa/basic_coverage/test_instr_method.vb b/basic/qa/basic_coverage/test_instr_method.vb
index 716aa215878b..47fa7a94ede1 100644
--- a/basic/qa/basic_coverage/test_instr_method.vb
+++ b/basic/qa/basic_coverage/test_instr_method.vb
@@ -6,12 +6,17 @@
'
Function doUnitTest as Integer
- dim aString as Variant
+
+ doUnitTest = 0
+
+ Dim aString As Variant
aString = "Hello"
' InStr
- If ( InStr( 1, aString, "l", 1) <> 3 ) Then
- doUnitTest = 0
- Else
- doUnitTest = 1
- End If
+ If (InStr(1, aString, "l", 1) <> 3) Then Exit Function
+
+ ' tdf#139840 - case-insensitive operation for non-ASCII characters
+ If (InStr(1, "α", "Α", 1) <> 1) Then Exit Function
+
+ doUnitTest = 1
+
End Function
diff --git a/basic/qa/vba_tests/instr.vb b/basic/qa/vba_tests/instr.vb
index 74f7e2f755d4..3ced2a07c8ca 100644
--- a/basic/qa/vba_tests/instr.vb
+++ b/basic/qa/vba_tests/instr.vb
@@ -30,6 +30,9 @@ Sub verify_testInStr()
TestUtil.AssertEqual(InStr(1, SearchString, SearchChar, 0), 9, "InStr(1, SearchString, SearchChar, 0)")
TestUtil.AssertEqual(InStr(1, SearchString, "W"), 0, "InStr(1, SearchString, ""W"")")
+ ' tdf#139840 - case-insensitive operation for non-ASCII characters
+ TestUtil.AssertEqual(InStr(1, "α", "Α", 1), 1, "InStr(1, ""α"", ""Α"", 1)")
+
Exit Sub
errorHandler:
TestUtil.ReportErrorHandler("verify_testInStr", Err, Error$, Erl)
diff --git a/basic/source/runtime/methods.cxx b/basic/source/runtime/methods.cxx
index 843c85b4860f..73bfe7fbc2d0 100644
--- a/basic/source/runtime/methods.cxx
+++ b/basic/source/runtime/methods.cxx
@@ -887,8 +887,13 @@ void SbRtl_InStr(StarBASIC *, SbxArray & rPar, bool)
OUString aStr1 = rPar.Get(nFirstStringPos)->GetOUString();
OUString aToken = rToken;
- aStr1 = aStr1.toAsciiUpperCase();
- aToken = aToken.toAsciiUpperCase();
+ // tdf#139840 - case-insensitive operation for non-ASCII characters
+ const css::lang::Locale& rLocale
+ = Application::GetSettings().GetLanguageTag().getLocale();
+ css::uno::Reference<i18n::XCharacterClassification> xCharClass
+ = vcl::unohelper::CreateCharacterClassification();
+ aStr1 = xCharClass->toUpper(aStr1, 0, aStr1.getLength(), rLocale);
+ aToken = xCharClass->toUpper(aToken, 0, aToken.getLength(), rLocale);
nPos = aStr1.indexOf( aToken, nStartPos-1 ) + 1;
}