Thread Tools Display Modes
01-04-13, 07:02 AM   #1
Anja
A Fallenroot Satyr
 
Anja's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2011
Posts: 27
special letters

Code:
dkp = {
["Fr\195\170em\195\162n"] = 56.00
}
How can i get This value


dkp.playername doenst work with special letters, can i first convert the playername string to this \170\162 Stuff? to get the right array key?

something like...

Code:
s = Frêemân
local function convert(s)


 return s -- like Fr\195\170em\195\162n
end

Last edited by Anja : 01-04-13 at 07:09 AM.
  Reply With Quote
01-04-13, 09:13 AM   #2
humfras
A Flamescale Wyrmkin
AddOn Author - Click to view addons
Join Date: Oct 2009
Posts: 131
dkp.blabla is the same as dkp["blabla"].

For a string value, use (e.g.)

local s = "blabla"
local val = dkp[s]
__________________
Author of VuhDo CursorCastBar OptiTaunt Poisoner RaidMobMarker
  Reply With Quote
01-04-13, 09:40 AM   #3
Anja
A Fallenroot Satyr
 
Anja's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2011
Posts: 27
but when the string value is with special character like é or â then i didnt find the array key because of this \015\102 in it, how can i convert the á into \016 ?! to match the key in the array?!
  Reply With Quote
01-04-13, 10:19 AM   #4
Dridzt
A Pyroguard Emberseer
 
Dridzt's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2005
Posts: 1,359
If we're talking about an in-game addon (.lua) then making sure you save your file as utf8 should suffice for saving and looking up keys without escaping characters.

That is save as [blâblâ] and look it up the same way.

If you have a web interface parsing saved variables, or you need to copy paste from in-game to a web site or some other interaction of the kind, provide more information about what exactly you're trying to accomplish and in what environment

Last edited by Dridzt : 01-04-13 at 10:22 AM.
  Reply With Quote
01-04-13, 10:48 AM   #5
Tim
A Rage Talon Dragon Guard
 
Tim's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2008
Posts: 308
Yeah the question here is why your string contains utf8 format instead of plain text. As Driz asked, are you using an external dkp extracting addon or something?

Saving as...
Code:
dkp = {
["Frêemân"] = 56.00
}
and then grabbing the data by..
Code:
dkp["Frêemân"]
If it's a must to where you have to use utf8 then you would want to create a table with all the special characters in it with their utf format and then making a replace/convert function to use that table.
__________________
AddOns: Tim @ WoWInterface
Characters: Mage, Priest, Devoker, Pally
Battle Tag: Mysterio#11164
Current PC Setup: PCPartPicker List
  Reply With Quote
01-04-13, 10:54 AM   #6
Anja
A Fallenroot Satyr
 
Anja's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2011
Posts: 27
yepp the data format ist only like

["B\195\162be"] or
["Dw\195\161yna"] = {
["DKP"] = 100.00
}

the data comes from http://absence-gilde.com/eqdkp/getdkp.php eqdkp
the old addon "GetDKP" doesnt work, so i codet my own little "whisper to get dkp" addon.

it works fine, (with my very bad code *g*) but the utf8 problem let it only work for normal character names.

Code:
SLASH_DKP1 = "/dkp"
SlashCmdList["DKP"] = function(msg, editBox)
    -- change the text on the editBox.
    print("Du hast "..gdkp.players.Ikuria.DKP.. "DKP")
end

local function filter(self, event, msg, sender)
	split = string.match(msg, " (%w+)")
	if (split) then
	firstchar = split:sub(1,1)
	firstchar = firstchar:upper()
	split = split:sub(2)
	split = firstchar .. split
	end
	if (self:GetName() == "ChatFrame1") then
		if (gdkp.players[split]) then
			SendChatMessage(split.." hat "..gdkp.players[split].DKP.. " DKP aus ".. gdkp.players[split].rcount .. " gespielten Raids.", "WHISPER", nil, sender)
			return true
		else
			if (msg == "!dkp" or msg == "?dkp") then
				if (gdkp.players[sender]) then
					SendChatMessage("Du hast "..gdkp.players[sender].DKP.. " DKP aus ".. gdkp.players[sender].rcount .. " gespielten Raids.", "WHISPER", nil, sender)
					return true
				else 
					SendChatMessage("Der Spieler "..sender.. " wurde nicht gefunden.", "WHISPER", nil, sender)
					return true
				end
			end
		end
	end
	if (self:GetName() == "ChatFrame5") then
		if (gdkp.players[split] or msg == "!dkp" or msg == "?dkp") then
			return true
		end
	end
end


local function HideOutgoing(self, event, msg, author, ...)
	if (self:GetName() == "ChatFrame5") then
		if (msg == string.match(msg, "Du hast %d+ DKP aus %d+ gespielten Raids.")) then 
			UIErrorsFrame:AddMessage(author.." fragte seine DKP ab.", 1.0, 0.0, 0.0, 53, 5);
			return true	
		end
		if (msg == string.match(msg, "%w+ hat %d+ DKP aus %d+ gespielten Raids.")) then
			split = string.match(msg, "(%w+)")
			firstchar = split:sub(1,1)
			firstchar = firstchar:upper()
			split = split:sub(2)
			split = firstchar .. split
			UIErrorsFrame:AddMessage(author.." fragte "..split.."'s DKP ab.", 1.0, 0.0, 0.0, 53, 5);
			return true
		end
		if (msg == string.match(msg, "Der Spieler %w+ wurde nicht gefunden.")) then
			return true
		end
	else
		return true
	end
end

ChatFrame_AddMessageEventFilter("CHAT_MSG_WHISPER_INFORM", HideOutgoing)
ChatFrame_AddMessageEventFilter("CHAT_MSG_WHISPER", filter)
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » special letters

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off