string.lower() problem
 

News:

29 December 2022 - PtokaX 0.5.3.0 (20th anniversary edition) released...
11 April 2017 - PtokaX 0.5.2.2 released...
8 April 2015 Anti child and anti pedo pr0n scripts are not allowed anymore on this board!
28 September 2015 - PtokaX 0.5.2.1 for Windows 10 IoT released...
3 September 2015 - PtokaX 0.5.2.1 released...
16 August 2015 - PtokaX 0.5.2.0 released...
1 August 2015 - Crowdfunding for ADC protocol support in PtokaX ended. Clearly nobody want ADC support...
30 June 2015 - PtokaX 0.5.1.0 released...
30 April 2015 Crowdfunding for ADC protocol support in PtokaX
26 April 2015 New support hub!
20 February 2015 - PtokaX 0.5.0.3 released...
13 April 2014 - PtokaX 0.5.0.2 released...
23 March 2014 - PtokaX testing version 0.5.0.1 build 454 is available.
04 March 2014 - PtokaX.org sites were temporary down because of DDOS attacks and issues with hosting service provider.

Main Menu

string.lower() problem

Started by Light, 15 December, 2006, 14:20:54

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Light

Hi to all, all word replace scripts don't work with russian, becaue function string.lower don't understand it.. how may fix this problem?

Madman

Use a table...
before string.lower the text, do a for loop and gsub the letters.
If you can't figuer it out, i got an example code
We suffer in silence, we lurk in the shadows, we kill in the night
Site currently down, ETA of returning online is 2099 ;p

Herodes

There must be something to do with os.setlocale :
Quote from: Lua5.1Manual
os.setlocale (locale [, category])

Sets the current locale of the program. locale is a string specifying a locale; category is an optional string describing which category to change: "all", "collate", "ctype", "monetary", "numeric", or "time"; the default category is "all". The function returns the name of the new locale, or nil if the request cannot be honored.

When called with nil as the first argument, this function only returns the name of the current locale for the given category.

I believe yours may work like:
os.setlocale('ru_RU')

speedX

oh man, those hyper-difficult codes make me feel sick :(
Is there any site or module wich contains all the codes of ptokax??
Thanking You,

speedX

Herodes

Quote from: speedX on 15 December, 2006, 20:04:47
oh man, those hyper-difficult codes make me feel sick :(
Is there any site or module wich contains all the codes of ptokax??
what codes ?
do you mean 'ru_RU', 'el_GR' ?
check this out :)

Light

os.setlocale('ru_RU') - no effect..
Madman, please give me example

Herodes

Quote from: Light on 16 December, 2006, 21:52:11
os.setlocale('ru_RU') - no effect..
Madman, please give me example
Where did you use it in the script? I suppose you should use it in Main().

function Main()
os.setlocale("ru_RU")
assert(os.setlocale() == "ru_RU", "The locale wasn't set")
end

bastya_elvtars

IIRC you can directly assert os.setlocale("ru_RU"), since it returns nil on failure.
Everything could have been anything else and it would have just as much meaning.

Light

#8
Yes, i use it in main(). it returns nil..
This problem appers in lua 5.1 version, in older versions string functions processing normaly

Madman

BadLetters = {
	["?"] = "?",
	["?"] = "?",
	["?"] = "?",
}

function ChatArrival(curUser,data)
	local data = string.sub(data,1,-2)
	local s,e,text = string.find(data,"%b<>(.+)")
	for Upper,Lower in pairs(BadLetters) do
		if string.find(text,Upper) then
			text = string.gsub(text,Upper,Lower)
		end
	end
	SendToAll(curUser.sName,string.lower(text)) return 1
end


Hopes it helps...
We suffer in silence, we lurk in the shadows, we kill in the night
Site currently down, ETA of returning online is 2099 ;p

SMF spam blocked by CleanTalk